//var domainName="http://192.168.1.132/";//zh
//var domainName="http://192.168.0.7:8080/";//pk
//var domainName="http://192.168.0.105:8080/";//yh
//var domainName="http://192.168.0.105:8080/";//yl
// var domainName = "http://192.168.2.123:8080/";//zh
 var domainName = "http://admin.secjf.com//"//fwq
// var domainName = "http://127.0.0.1:8080/"//fwq
// var domainName = "http://admin.secjf.cn/"//testfwq
angular.module("myApp.controllers", ["ionic"])
	.controller("Home", ["$scope", "$state", "$http", "$rootScope", "$ionicPopup", "$ionicLoading", function ($scope, $state, $http, $rootScope, $ionicPopup, $ionicLoading) {//主页
		var allChoose = document.getElementsByClassName("chooseBtn");
		//      $scope.alltableList=[{objectSid:0,name:"一号桌",size:"6人桌",isCheck:false,tableStatus:0},
		//      {objectSid:1,name:"二号桌",size:"4人桌",isCheck:false,tableStatus:1,foodList:[{foodName:"鱼香肉丝",piece:"15",num:1},{foodName:"红烧肉",piece:"40",num:1},{foodName:"土豆肉丝",piece:"20",num:1}]},
		//      {objectSid:2,name:"三号桌",size:"8人桌",isCheck:false,tableStatus:2},{objectSid:3,name:"四号桌",size:"8人桌",isCheck:false,tableStatus:3}];
		//      $scope.showTable=$scope.alltableList;
		$scope.amountPaid = 0;//结账已付金额
		$scope.lineUpIsPersonNum = 0;//排队键盘输入的是哪个
		$scope.lineUpPersonNum = "";//排队就餐人数
		$scope.lineUpTelNum = "";//排队号码
		$scope.ctrlScope = $scope;
		$scope.lineUpseats = "";//排队种类 
		$scope.chooseLineUpSize = 0;//排队列表人数
		$scope.tableFoodNum = "";
		$scope.choosePay = 0;//选则支付方式
		$scope.choosePayName = "现金";//选则支付方式名字
		$scope.moneychange = 0;//找零
		$scope.nowPayNum = 0;//实付金额
		$scope.combineTableShow = false;//并台窗口显示
		$scope.listUpTableShow = false;//排队选桌页面显示
		$scope.jmobj = $scope
		$scope.jm = '' //简码搜索
		$scope.tipContent = '';// 提示信息
		$scope.okType = 1;
		$scope.memberList = [];
		//      $scope.inventoryStatue=0;//显示的清单状态
		$scope.cashpay = "";//现金支付
		$scope.cardpay = "";//银联卡支付
		$scope.showFastFoodSettleAccount = false;//快餐结账窗口
		$scope.vippay = "";//会员支付
		$scope.wxpay = "";//微信支付
		$scope.zfbpay = "";//支付宝支付
		$scope.loginName = "";//登录账号
		$scope.loginPassword = "";//登录密码
		$scope.isLogin = false;//登录状态
		$scope.tableStatue = 0;//餐台页面桌面状态
		$scope.settleAccountsPayNum = false;//支付金额键盘
		$scope.settlePayNum = "";//支付金额
		$scope.showModule = 1;//显示的页面
		$scope.tableSize = 0;//餐台页面桌面的大小;
		$scope.settleVipInfor = "";//结账VIP信息
		$scope.tableArea = 0;//餐台页面桌位的区域
		$scope.showTechnicalSupport = false;//显示技术支持
		$scope.showHideVipbg = false;//键盘背景
		$scope.copyOrderTableSize = 0;//复制整单桌面大小
		$scope.copyOrderTableArea = 0;//复制整单桌面区域
		$scope.showEdit = false;//点餐编辑窗口
		$scope.showHideBox = false;//点开窗口后下面的遮罩
		$scope.showRequire = false;//特殊要求窗口
		$scope.showRemark = false;//备注窗口
		$scope.settleHaveVip = false;//结账有会员
		//      $scope.presentFoodBox=false;//赠餐窗口
		$scope.returnDishes = false;//退菜窗口
		$scope.settleVipNum = ""//结账VIP键盘
		$scope.foodStatus = 0;//菜品状态
		$scope.changeStatus = false;//修改状态窗口
		$scope.callUp = false;//叫起窗口
		$scope.callUpStatus = 0;//叫起状态
		$scope.foodChangeTable = false;//单品转菜窗口
		$scope.changeTable = false;//转桌窗口
		$scope.copyOrderShow = false;//复制整单窗口
		$scope.foodSearchMode = 0;//菜品搜索方式
		$scope.thistablePage = 1;//餐台页面现在的页数
		$scope.thisFoodPage = 1;//食物页数
		$scope.thisFoodOrderPage = 1;//食物订单数
		$scope.getBackFastFoodShow = false;//快餐页面取回窗口
		$scope.showHidebg = false;//弹窗遮罩
		$scope.showOpenTable = false;//开台弹窗
		// 估清弹框
		$scope.estimate = false;

		$scope.showOpenMune = false;//菜单弹框
		$scope.waiterChoose = {};//服务员
		$scope.showSettleAccount = false;//显示结账窗口
		$scope.foodCategory = 0;//菜单种类
		$scope.foodStartPrice = 0//开始价格
		$scope.foodEndPrice = 10000;//结束价格
		$scope.thisCopytablePage = 1;//复制整单餐台页数
		$scope.thisFastFoodOrderPage = 1;//快餐订单页数
		$scope.allThisFastFoodOrderPage = 1;//取回页面页数
		$scope.haveVipCard = false;//显示会员卡
		$scope.inventoryStatus = 0;//清单状态
		$scope.vipCardNum = "";//查找的Vip号
		$scope.settleAccountsVipNum = false;//vip键盘显示
		$scope.billCode = "";//清单查询字段
		$scope.getBackNum = "";//取回牌号
		$scope.tableOrderPage = 1;//显示订单页数
		$scope.inventoryBeginTime = "";//清单开始时间
		$scope.inventoryEndTime = "";//清单结束时间
		$scope.thisinventoryPage = 1;//清单页面;
		$scope.inventoryType = 0;//清单来源
		$scope.showVipInfor = 0;//vip页面显示的信息
		$scope.inventoryStatusList = [{ objectSid: 0, name: "全部" }, { objectSid: 1, name: "已结账" }, { objectSid: 2, name: "未结账" }, { objectSid: 3, name: "反结账" }]
		$scope.inventoryStatus = $scope.inventoryStatusList[0];//清单状态
		$scope.unMuneIdArr = [];//估清产品id数组
		$scope.cancelMuneArr = [];//取消估清产品id数组

        // 登录页加入回车登录
        $scope.enterEvent = function(e){
            if(e.keyCode == 13){
                $scope.goLogin()
            }
        }

		$scope.chooseThis = function (index) {//点击右侧按钮选择显示页面
			//var layer = layui.layer;  //layer初始化

			if (index == $scope.showModule) {
				return;
			}
			$scope.haveVipCard = false;//显示会员卡
			$scope.showVipInfor = 0;//会员页面显示信息
			$scope.rechargeNum = "";//会员卡充值金额
			$scope.vipPassword = "";//会员密码
			$scope.showModule = index;
			$scope.newVipName = "";//新会员名字
			$scope.newVipNum = "";//新会员卡号
			if (index == 1) {
				$scope.getTablesList();
			} else if (index == 2) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/snack/createSnack',
					data: { restaurantId: $scope.myInfor.restaurantId, type: 1 },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					if (data.message == 0) {
						$ionicLoading.hide();
						$scope.fastFoodOrderInfor = data;
						$scope.fastFoodTitleNum = false;
						$scope.chooseFastOrderFood = "";
						$scope.fastFoodOrderList = [];
						$scope.foodCategory = 0;//菜单种类
						$scope.foodStartPrice = 0//开始价格
						$scope.foodEndPrice = 10000;//结束价格
						$scope.getFoodList();
					}

				}).error(function (err) {
				});
			} else if (index == 4) {
				$scope.getInventoryList();
			} else if (index == 6) {
				$scope.getLineUpList();
			} else if (index == 5) {
				$scope.getMemberList();
			}
		}
		/**
		 * 获取会员
		 */
		$scope.getMemberList = function () {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/member/getMembersByRestaurantId',
				data: {
					restaurantId: $scope.myInfor.restaurantId,
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				// 关闭加载框
				$ionicLoading.hide();
				$scope.memberList = data.data

				$scope.haveCheckCopy = false;
			}).error(function (err) {
				console.log(err);
			});


		}
		/*清除支付*/
		$scope.clearPay = function () {
			$scope.choosePay = 15;
			$scope.choosePayName = ""
			$scope.cashpay = "";
			$scope.cardpay = "";
			$scope.vippay = "";
			$scope.wxpay = "";
			$scope.zfbpay = "";
			$scope.settlePayNum = "";
			$scope.amountPaid = 0;
			$scope.getAmountPaid();
		}
		/*计算已支付的*/
		$scope.getAmountPaid = function () {
			$scope.nowPayNum = Number($scope.settlePayNum);
			if ($scope.choosePay == 0) {
				$scope.cashpay = Number($scope.settlePayNum);

			} else if ($scope.choosePay == 1) {
				$scope.cardpay = Number($scope.settlePayNum);

			} else if ($scope.choosePay == 2) {
				$scope.vippay = Number($scope.settlePayNum);

			} else if ($scope.choosePay == 3) {
				$scope.wxpay = Number($scope.settlePayNum);
			} else if ($scope.choosePay == 4) {
				$scope.zfbpay = Number($scope.settlePayNum);

			}

			$scope.amountPaid += Number($scope.settlePayNum);
			if ($scope.amountPaid == "") {
				$scope.amountPaid = 0;
			}
			if ($scope.shouldPay - $scope.amountPaid < 0) {
				$scope.waitToPay = 0;
				$scope.moneychange = $scope.amountPaid - $scope.shouldPay;
				$scope.moneychange = $scope.moneychange.toFixed(2);
			} else {
				$scope.waitToPay = $scope.shouldPay - $scope.amountPaid;
				$scope.moneychange = 0;
			}
			$scope.settlePayNum = "";
			$scope.hidekey()
		}
		$scope.combineTableArea = 0;
		$scope.combineTableSize = 0;
		/*打开合台窗口*/
		$scope.openCombineTable = function () {
			$scope.combineTablePart = 0;
			$scope.getAllCombineTable();
			$scope.showHidebg = true;
			$scope.combineTableShow = true;
			$scope.chooseAllCombineTable = [];
		}
		/*改变合台桌面大小*/
		$scope.combineOrderChooseTableSize = function (index) {
			$scope.combineTableSize = index;
			$scope.getAllCombineTable();
		}
		/*改变合台桌面区域*/
		$scope.combineOrderChooseTableArea = function (index) {
			$scope.combineTableArea = index;
			$scope.getAllCombineTable();
		}
		/*合台上一页*/
		$scope.combineOrderLastPage = function () {
			if ($scope.thisCombinetablePage > 1) {
				$scope.thisCombinetablePage--;
				$scope.showCombineTable = $scope.pageCombineTableList[$scope.thisCombinetablePage - 1];
			}
		}
		/*合台下一页*/
		$scope.combineOrderNextPage = function () {
			if ($scope.thisCombinetablePage < $scope.tableCombinePageNum) {
				$scope.thisCombinetablePage++;
				$scope.showCombineTable = $scope.pageCombineTableList[$scope.thisCombinetablePage - 1];
			}
		}
		/*选择要和台的桌面*/
		$scope.chooseThisCombineTable = function (index) {
			for (var s = 0; s < $scope.showCombineTable.length; s++) {
				if ($scope.showCombineTable[s].OBJECT_SID == index.OBJECT_SID) {
					$scope.showCombineTable[s].isCheck = !$scope.showCombineTable[s].isCheck;
				}
			}
			$scope.chooseAllCombineTable = [];
			if ($scope.pageCombineTableList) {
				for (var m = 0; m < $scope.pageCombineTableList.length; m++) {
					for (var n = 0; n < $scope.pageCombineTableList[m].length; n++) {
						if ($scope.pageCombineTableList[m][n].isCheck) {
							$scope.chooseAllCombineTable.push($scope.pageCombineTableList[m][n]);
						}
					}
				}
			} else {
				for (var i = 0; i < $scope.showCombineTable.length; i++) {
					if ($scope.showCombineTable[i].isCheck) {
						$scope.chooseAllCombineTable.push($scope.showCombineTable[i]);
					}
				}
			}

		}
		/*获取合台餐台*/
		$scope.getAllCombineTable = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/desk/getDeskByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId, categoryId: $scope.combineTableArea, seats: $scope.combineTableSize, state: 3 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$scope.combineTableCategorys = data.categorys;
				if (data.desks.length > 15) {
					$scope.thisCombinetablePage = 1;
					$scope.pageCombineTableList = [];
					$scope.tableCombinePageNum = Math.ceil(data.desks.length / 15);
					for (var m = 0; m < $scope.tableCombinePageNum; m++) {
						var oneList = []
						for (n = 15 * m; n < 15 * (m + 1); n++) {
							if (n > data.desks.length - 1) {
								break;
							}
							oneList.push(data.desks[n]);
						}
						$scope.pageCombineTableList.push(oneList);
					}
					$scope.showCombineTable = $scope.pageCombineTableList[$scope.thisCombinetablePage - 1];
				} else {
					$scope.pageCombineTableList = false;
					$scope.showCombineTable = data.desks;
					$scope.tableCombinePageNum = 1;
					$scope.thisCombinetablePage = 1;
				}
				$scope.haveCheckCopy = false;
			}).error(function (err) {
			});
		}
		/*选择空台面*/
		$scope.chooseThisTargetTable = function (index) {
			$scope.myChooseTargetTable = index;
			if ($scope.pageTargetTableList) {
				for (var m = 0; m < $scope.pageTargetTableList.length; m++) {
					for (var n = 0; n < $scope.pageTargetTableList[m].length; n++) {
						if ($scope.pageTargetTableList[m][n].OBJECT_SID == index.OBJECT_SID) {
							$scope.pageTargetTableList[m][n].isCheck = true;
						} else {
							$scope.pageTargetTableList[m][n].isCheck = false;
						}
					}
				}
			} else {
				for (var s = 0; s < $scope.showTargetTable.length; s++) {
					if ($scope.showTargetTable[s].OBJECT_SID == index.OBJECT_SID) {
						$scope.showTargetTable[s].isCheck = true;
					} else {
						$scope.showTargetTable[s].isCheck = false;
					}
				}
			}
		}
		/*改变合台空桌面大小*/
		$scope.targetOrderChooseTableSize = function (index) {
			$scope.targetTableSize = index;
			$scope.getAllTargetTable();
		}
		/*改变合台空桌面区域*/
		$scope.targetOrderChooseTableArea = function (index) {
			$scope.targetTableArea = index;
			$scope.getAllTargetTable();
		}
		/*空台上一页*/
		$scope.targetOrderLastPage = function () {
			if ($scope.thisTargettablePage > 1) {
				$scope.thisTargettablePage--;
				$scope.showTargetTable = $scope.pageTargetTableList[$scope.thisTargettablePage - 1];
			}
		}
		/*空台下一页*/
		$scope.targetOrderNextPage = function () {
			if ($scope.thisTargettablePage < $scope.tableTargetPageNum) {
				$scope.thisTargettablePage++;
				$scope.showTargetTable = $scope.pageTargetTableList[$scope.thisTargettablePage - 1];
			}
		}
		/*获取合台空餐台*/
		$scope.getAllTargetTable = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/desk/getDeskByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId, categoryId: $scope.targetTableArea, seats: $scope.targetTableSize, state: 1 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$scope.targetTableCategorys = data.categorys;
				if (data.desks.length > 15) {
					$scope.thisTargettablePage = 1;
					$scope.pageTargetTableList = [];
					$scope.tableTargetPageNum = Math.ceil(data.desks.length / 15);
					for (var m = 0; m < $scope.tableTargetPageNum; m++) {
						var oneList = []
						for (n = 15 * m; n < 15 * (m + 1); n++) {
							if (n > data.desks.length - 1) {
								break;
							}
							oneList.push(data.desks[n]);
						}
						$scope.pageTargetTableList.push(oneList);
					}
					$scope.showTargetTable = $scope.pageTargetTableList[$scope.thisTargettablePage - 1];
				} else {
					$scope.pageTargetTableList = false;
					$scope.showTargetTable = data.desks;
					$scope.tableTargetPageNum = 1;
					$scope.thisTargettablePage = 1;
				}
				$scope.haveCheckCopy = false;
			}).error(function (err) {
				console.log(err);
			});
		}
		/*确认并台*/
		$scope.affirmCombine = function () {
			if ($scope.myChooseTargetTable) {
				var allCombineTableId = "";
				for (var s = 0; s < $scope.chooseAllCombineTable.length; s++) {
					if (allCombineTableId == "") {
						allCombineTableId += $scope.chooseAllCombineTable[s].OBJECT_SID;
					} else {
						allCombineTableId = allCombineTableId + ',' + $scope.chooseAllCombineTable[s].OBJECT_SID;
					}
				}
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/order/mergeTable',
					data: { tableList: allCombineTableId, tableId: $scope.myChooseTargetTable.OBJECT_SID },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					$ionicLoading.hide();
					$scope.hideAll();
					$scope.getTablesList();
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*选择目标餐台*/
		$scope.chooseTargetTable = function () {
			if ($scope.chooseAllCombineTable.length > 1) {
				$scope.targetTableSize = 0;
				$scope.targetTableArea = 0;
				$scope.getAllTargetTable();
				$scope.combineTablePart = 1;
				$scope.myChooseTargetTable = false;
			}
		}
		$scope.tuisong = function () {
			// 建立连接对象（还未发起连接）
			var socket = new SockJS(domainName + "/socket/chat/");
			// 获取 STOMP 子协议的客户端对象
			var stompClient = Stomp.over(socket);

			// 向服务器发起websocket连接并发送CONNECT帧
			stompClient.connect(
				{},
				function connectCallback(frame) {
					// 连接成功时（服务器响应 CONNECTED 帧）的回调方法
					stompClient.subscribe('/topic/subscribe', function (response) {
						//发消息自动订阅
						//setMessageInnerHTML("已成功订阅/topic/subscribeTest");
						var returnData = JSON.parse(response.body);
						if (returnData.status == "10000") {
							//		                	b(returnData.billId,returnData.billCode);
							$scope.getTablesList();
						} else if (returnData.status == "10001") {
							$scope.getTablesList();
						} else if (returnData.status == "10002") {
							$scope.getTablesList();
						}
					});
				},
				function errorCallBack(error) {
					// 连接失败时（服务器响应 ERROR 帧）的回调方法
					console.log("连接失败");
				}
			);
		}
		/*选择支付方式*/
		$scope.chooseThisPayway = function (index, x) {
			$scope.choosePay = index;//选则支付方式
			$scope.choosePayName = x;//选则支付方式名字
			$scope.nowPayNum = 0;//实付金额
		}
		/*选择清单来源*/
		$scope.chooseInventoryStatus = function (index) {
			$scope.inventoryType = index;
			$scope.getInventoryList();
		}
		/*清单详情菜单上一页*/
		$scope.inventoryFoodLastPage = function () {
			if ($scope.thisinventoryFoodPage == 1) {
				return
			}
			$scope.thisinventoryFoodPage--;
			$scope.inventoryFoodList = $scope.pageInventoryFoodList[$scope.thisinventoryFoodPage - 1];
		}
		/*清单详情菜单下一页*/
		$scope.inventoryFoodNextPage = function () {
			if ($scope.thisinventoryFoodPage >= $scope.inventoryFoodPageNum) {
				return
			}
			$scope.thisinventoryFoodPage++;
			$scope.inventoryFoodList = $scope.pageInventoryFoodList[$scope.thisinventoryFoodPage - 1];
		}
		/*显示清单详情*/
		$scope.showInventoryDetails = function (index) {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/order/getBillHisInfo',
				data: {
					type: index.type,
					status: index.status,
					billcode: index.billcode,
					billId: index.object_id
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				$scope.showModule = 9;
				$scope.inventoryInfor = data.billinfo[0];
				$scope.thisinventoryFoodPage = 1;
				if (data.billlineinfo.length > 8) {
					$scope.thisinventoryFoodPage = 0;
					$scope.pageInventoryFoodList = [];
					$scope.inventoryFoodPageNum = Math.ceil(data.billlineinfo.length / 13);
					for (var m = 0; m < inventoryFoodPageNum; m++) {
						var oneList = []
						for (n = 13 * m; n < 13 * (m + 1); n++) {
							if (n > data.billlineinfo.length - 1) {
								break;
							}
							oneList.push(data.billlineinfo[n]);
						}
						$scope.pageInventoryFoodList.push(oneList);
					}
					$scope.inventoryFoodList = $scope.pageInventoryFoodList[$scope.thisinventoryFoodPage - 1];
				} else {
					$scope.pageInventoryFoodList = false;
					$scope.inventoryFoodList = data.billlineinfo;
					$scope.inventoryFoodPageNum = 1;
					$scope.thisinventoryFoodPage = 1;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*搜索清单*/
		$scope.searchInventory = function () {
			var startDate = document.getElementById("startDate").value;
			var endDate = document.getElementById("endDate").value;
			$scope.inventoryBeginTime = startDate;
			$scope.inventoryEndTime = endDate;
			$scope.getInventoryList();
		}
		/*获取清单列表*/
		$scope.getInventoryList = function () {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/order/getBillHisList',
				data: {
					restaurant_id: $scope.myInfor.restaurantId,
					status: $scope.inventoryStatus.objectSid,
					billCode: $scope.billCode,
					type: $scope.inventoryType,
					beginDate: $scope.inventoryBeginTime,
					endDate: $scope.inventoryEndTime
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {

				$ionicLoading.hide();
				//				   	   $scope.inventoryList=data.billhis;
				$scope.InventoryListLength = data.billhis.length;
				if (data.billhis.length > 13) {
					$scope.pageinventoryList = [];
					$scope.inventoryPageNum = Math.ceil(data.billhis.length / 13);
					for (var m = 0; m < $scope.inventoryPageNum; m++) {
						var oneList = []
						for (n = 13 * m; n < 13 * (m + 1); n++) {
							if (n > data.billhis.length - 1) {
								break;
							}
							oneList.push(data.billhis[n]);
						}
						$scope.pageinventoryList.push(oneList);
					}
					$scope.inventoryList = $scope.pageinventoryList[$scope.thisinventoryPage - 1];
				} else {
					$scope.pageinventoryList = false;
					$scope.inventoryList = data.billhis;
					$scope.inventoryPageNum = 1;
					$scope.thisinventoryPage = 1;
				}
				$scope.canTheCheckout = false;
			}).error(function (err) {
				console.log(err);
			});
		}
		/*补打小票*/
		$scope.toBuyTicket = function () {
			if ($scope.canTheCheckout) {
				console.log($scope.chooseOneInventory);
				if ($scope.chooseOneInventory.type == 3) {
					fastFoodA($scope.chooseOneInventory.billcode);
				} else {
					c($scope.chooseOneInventory.billcode);
				}
			}
		}
		/*清单反结账*/
		$scope.inventoryTheCheckout = function () {
			if ($scope.canTheCheckout && $scope.checkInventory.length) {
				for (var s = 0; s < $scope.checkInventory.length; s++) {
					if (s == 0) {
						$scope.checkoutInventorybillCode = $scope.checkInventory[s].billcode;
					} else {
						$scope.checkoutInventorybillCode = $scope.checkoutInventorybillCode + "," + $scope.checkInventory[s].billcode;
					}
				}
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/order/checkout',
					data: { bill_code: $scope.checkoutInventorybillCode },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					if (data.code == 0) {
						$ionicLoading.hide();
						$scope.getInventoryList();
						$scope.checkInventory = [];
					}
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*清单上一页*/
		$scope.inventoryLastPage = function () {
			if ($scope.thisinventoryPage == 1) {
				return;
			}
			$scope.thisinventoryPage--;
			$scope.inventoryList = $scope.pageinventoryList[$scope.thisinventoryPage - 1];
		}
		/*清单下一页*/
		$scope.inventoryNextPage = function () {
			if ($scope.thisinventoryPage >= $scope.inventoryPageNum) {
				return;
			}
			$scope.thisinventoryPage++;
			$scope.inventoryList = $scope.pageinventoryList[$scope.thisinventoryPage - 1];
		}
		/*选择清单中的一行*/
		$scope.chooseThisInventory = function (index) {
			$scope.chooseOneInventory = index;
			$scope.canTheCheckout = true;
			if ($scope.pageinventoryList) {
				for (var i = 0; i < $scope.pageinventoryList.length; i++) {
					for (var n = 0; n < $scope.pageinventoryList[i].length; n++) {
						$scope.pageinventoryList[i][n].isCheck = false;
					}

				}
			}
			for (var s = 0; s < $scope.inventoryList.length; s++) {
				if ($scope.inventoryList[s].object_id == index.object_id) {
					$scope.inventoryList[s].isCheck = true;
				} else {
					$scope.inventoryList[s].isCheck = false;
				}
			}
		}
		/*显示结账窗口*/
		$scope.showSettle = function () {
			if ($scope.canSettle && $scope.canSettleOne) {
				$scope.getTableInfor();
				$http({
					method: 'post',
					url: domainName + '/cas/order/malingamount',
					data: {
						consume_money: $scope.chooseTableBill.totalPrice
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					$scope.showHidebg = true;
					$scope.showSettleAccount = true;
					$scope.shouldPay = data.money;
					$scope.waitToPay = data.money;
					$scope.changeMoneyNum = data.malingamount;
					$scope.settleMark = data.description;
				}).error(function (err) {
					console.log(err);
				});

			}

		}/*餐台确定结账*/
		$scope.toTableSettle = function () {	
			if ($scope.waitToPay == 0) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				console.log($scope.chooseTableBill.totalPrice);
				a($scope.chooseTableBill.OBJECT_SID);
				if ($scope.settleVipInfor == "") {
					$scope.settleVipInfor = { memberDo: { objectSid: 0 } };
				}
				var phone = $scope.settleVipNum==""?$scope.settleVipInfor.memberDo.phone:$scope.settleVipNum
				console.log($scope.settleVipInfor);
				$http({
					method: 'post',
					url: domainName + '/cas/order/settleaccounts',
					data: {
						bill_code: $scope.chooseTableBill.BILL_CODE,
						desk_id: $scope.showTableInfor.OBJECT_SID,
						consume_money: $scope.chooseTableBill.totalPrice,
						real_money: $scope.amountPaid,
						trunc_money: $scope.changeMoneyNum,
						cashier: $scope.myInfor.username,
						cash: Number($scope.cashpay),
						unionpay: Number($scope.cardpay),
						member: Number($scope.vippay),
						wechat: Number($scope.wxpay),
						alipay: Number($scope.zfbpay),
						restaurantId: $scope.myInfor.restaurantId,
						phone: phone
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					$ionicLoading.hide();
					if (data.code == 0) {
						$scope.hideAll();
						$scope.backLastPage(1);
					}
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*快餐确定结账*/
		$scope.toFastFoodSettle = function () {
			if ($scope.waitToPay == 0) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/snack/payingSnack',
					data: {
						snackId: $scope.fastFoodOrderInfor.data.objectSid,
						cash: Number($scope.cashpay),
						upay: Number($scope.cardpay),
						club: Number($scope.vippay),
						weChat: Number($scope.wxpay),
						alipay: Number($scope.zfbpay)
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					if (data.msg == 0) {
						fastFoodA($scope.fastFoodOrderInfor.data.snackCode);
						fastFoodB($scope.fastFoodOrderInfor.data.snackCode);
						$scope.hideAll();
						$scope.addFastFood();
						$ionicLoading.hide();
					}
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*显示快餐结账窗口*/
		$scope.showFastFoodSettle = function () {
			if ($scope.fastFoodOrderList.length > 0) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/snack/payTrunc',
					data: {
						snackId: $scope.fastFoodOrderInfor.data.objectSid,
						money: $scope.fastFoodTitleNum[0].totalPrice,
						mark: $scope.fastFoodOrderInfor.last
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					$ionicLoading.hide();
					if (data.msg != 0) {
						return;
					}
					$scope.fastFoodSettleInfor = data.data;
					if (data.data.SnackLine.length > 9) {
						$scope.pageTableOrderList = [];
						$scope.tableOrderPageNum = Math.ceil(data.data.SnackLine.length / 9);
						for (var m = 0; m < $scope.tableOrderPageNum; m++) {
							var oneList = []
							for (n = 9 * m; n < 9 * (m + 1); n++) {
								if (n > data.data.SnackLine.length - 1) {
									break;
								}
								oneList.push(data.data.SnackLine[n]);
							}
							$scope.pageTableOrderList.push(oneList);
						}
						console.log($scope.pageTableOrderList);
						$scope.tableOrderList = $scope.pageTableOrderList[$scope.tableOrderPage - 1];
					} else {
						$scope.tableOrderList = data.data.SnackLine;
						$scope.tableOrderPage = 1;
						$scope.tableOrderPageNum = 1;
					}
					$scope.shouldPay = $scope.fastFoodSettleInfor.totalPrice;
					$scope.allPay = $scope.fastFoodTitleNum[0].totalPrice;
					$scope.waitToPay = $scope.fastFoodSettleInfor.totalPrice;
					$scope.showHidebg = true;
					$scope.showFastFoodSettleAccount = true;
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*结账vip键盘*/
		$scope.showKeyboard = function ($event) {
			$scope.settleAccountsVipNum = true;
			$scope.showHideVipbg = true;
			$event.stopPropagation();
		}


		//会员号码查询回车事件
		$scope.myKeyup = function ($event) {
			console.log($event);
			var keycode = window.event ? $event.keyCode : $event.which;
			console.log(keycode);
			
			if (keycode == 13) {
				$http({
					method: 'post',
					url: domainName + 'cas/member/getMemberByPhone',
					data: { restaurantId: $scope.myInfor.restaurantId, phone: $scope.settleVipNum },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					$scope.settleVipNum = "";
					$scope.showHideVipbg = false;
					$scope.settleAccountsVipNum = false;
					console.log(data);
					if (data.message == 1) {
						$scope.settleHaveVip = true;
						$scope.settleVipInfor = data;
					} else {
						layer.msg("会员不存在")
					}
				}).error(function (err) {
					console.log(err);
				});
			}
		};

		/*结账金额键盘*/
		$scope.showPayKeyboard = function () {
			if ($scope.choosePay > 4) {
				return;
			}
			$scope.settleAccountsPayNum = true;
			$scope.showHideVipbg = true;
		}
		/*关闭Vip键盘*/
		$scope.hidekey = function () {
			$scope.showHideVipbg = false;
			$scope.settleAccountsPayNum = false;
			$scope.settleAccountsVipNum = false;
		}
		/*结账清除vip*/
		$scope.clearVip = function () {
			$scope.settleHaveVip = false;
			$scope.settleVipInfor = "";
		}
		/*结账键盘按下*/
		$scope.settleVipanxia = function (a, b) {
			var foodNumKeyboard = document.getElementsByClassName("foodNumKeyboard")[0].children;
			foodNumKeyboard[a].style.backgroundColor = "#00b667";
			foodNumKeyboard[a].children[0].style.color = "#FFFFFF";
			if (b == "close") {
				$scope.settleVipNum = "";
			} else if (b == "clear") {
				$scope.settleVipNum = $scope.settleVipNum.substring(0, $scope.settleVipNum.length - 1);
			} else if (b == "ok") {
				if ($scope.settleVipNum == "") {
					return
				}

				$http({
					method: 'post',
					url: domainName + 'cas/member/getMemberByPhone',
					data: { restaurantId: $scope.myInfor.restaurantId, phone: $scope.settleVipNum },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					$scope.settleVipNum = "";
					$scope.showHideVipbg = false;
					$scope.settleAccountsVipNum = false;
					console.log(data);
					if (data.message == 1) {
						$scope.settleHaveVip = true;
						$scope.settleVipInfor = data;
					} else {
						layer.msg("会员不存在")
					}
				}).error(function (err) {
					console.log(err);
				});
			} else {
				$scope.settleVipNum += b;
			}
		}
		/*结账金额按钮按下*/
		$scope.settlePayanxia = function (a, b) {
			var foodNumKeyboard = document.getElementsByClassName("foodNumKeyboard")[0].children;
			foodNumKeyboard[a].style.backgroundColor = "#00b667";
			foodNumKeyboard[a].children[0].style.color = "#FFFFFF";
			if (b == "close") {
				$scope.settlePayNum = "";
			} else if (b == "clear") {
				$scope.settlePayNum = $scope.settlePayNum.substring(0, $scope.settlePayNum.length - 1);
			} else if (b == "ok") {
				if ($scope.settlePayNum == "" || isNaN(Number($scope.settlePayNum))) {
					$scope.settlePayNum = "";
					return
				}
				$scope.getAmountPaid()
			} else {
				$scope.settlePayNum += b;
			}
		}
		/*结账金额按钮放开*/
		$scope.settlePayfangkai = function () {
			$scope.isFocus = false;
			var foodNumKeyboard = document.getElementsByClassName("foodNumKeyboard")[0].children;
			for (var s = 0; s < foodNumKeyboard.length; s++) {
				foodNumKeyboard[s].style.backgroundColor = "#e6e7ea";
				foodNumKeyboard[s].children[0].style.color = "#5c5c5c";
			}
		}
		/*结账键盘放开*/
		$scope.settleVipfangkai = function () {
			$scope.isFocus = false;
			var foodNumKeyboard = document.getElementsByClassName("foodNumKeyboard")[0].children;
			for (var s = 0; s < foodNumKeyboard.length; s++) {
				foodNumKeyboard[s].style.backgroundColor = "#e6e7ea";
				foodNumKeyboard[s].children[0].style.color = "#5c5c5c";
			}
		}
		$scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
			if ($scope.showModule == 4) {
				lay('#version').html('-v' + laydate.v);
				//自定义颜色
				laydate.render({
					elem: '#startDate'
					, theme: '#c62f2f'
				});
				laydate.render({
					elem: '#endDate'
					, theme: '#c62f2f'
				});
			}

		})
		/*开新VIP卡*/
		$scope.newVipCard = function () {
			$http({
				method: 'post',
				url: domainName + 'cas/member/getLevelsByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.isActive == "Y") {
					$scope.vipLevels = data.LevelDOs;
					var myDate = new Date();
					$scope.thisMonth = myDate.getMonth() + 1;
					if ($scope.thisMonth < 10) {
						$scope.thisMonth = "0" + $scope.thisMonth;
					}
					$scope.setUpVipTime = myDate.getFullYear() + "-" + $scope.thisMonth + "-" + myDate.getDate();
					$scope.thisDay = myDate.getDate();
					$scope.showVipInfor = 3;
					$scope.newVipName = "";//新会员名字
					$scope.vipPassword = "";//会员密码
					$scope.newVipNum = "";//新会员卡号
					$scope.rechargeNum = "";//新卡充值金额
					$scope.changeVipLevel = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}

		/*搜索VIP*/
		$scope.searchVip = function () {
			console.log($scope.myInfor.restaurantId);
			console.log($scope.vipCardNum);

			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + 'cas/member/getMemberByPhone',
				data: { restaurantId: $scope.myInfor.restaurantId, phone: $scope.vipCardNum },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				$scope.vipCardNum = "";
				console.log(data);
				if (data.message == 1) {
					$scope.haveVipCard = true;
					$scope.vipInfor = data;
					console.log($scope.vipInfor);
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		$scope.vipTopUpRecharge = function () {
			if ($scope.haveVipCard) {
				$scope.showVipInfor = 1;
			}
		}
		/*vip编辑*/
		$scope.showCompile = function () {

			$http({
				method: 'post',
				url: domainName + 'cas/member/getLevelsByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.isActive == "Y") {
					$scope.vipLevels = data.LevelDOs;
					for (var s = 0; s < $scope.vipLevels.length; s++) {
						if ($scope.vipLevels[s].levelName == $scope.vipInfor.levelDO.levelName) {
							$scope.changeVipLevel = $scope.vipLevels[s];
						}
					}
					$scope.changeIntegral = $scope.vipInfor.memberDo.integral;
					$scope.showVipInfor = 2;
				}
			}).error(function (err) {

				console.log(err);
			});
		}

		/**
		 * 简码搜索
		 */
		$scope.e_enter = function () {

			$http({
				method: 'post',
				url: domainName + 'cas/food/getDeskByInitials',
				data: { restaurantId: $scope.myInfor.restaurantId, str: $scope.jm },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				$scope.foodCategorys = data.foodc;
				$scope.foodList = data.foodlist;

				if (data.foodlist.length > 30) {
					$scope.pageFoodList = [];
					$scope.foodPageNum = Math.ceil(data.foodlist.length / 30);
					for (var m = 0; m < $scope.foodPageNum; m++) {
						var oneList = []
						for (n = 30 * m; n < 30 * (m + 1); n++) {
							if (n > data.foodlist.length - 1) {
								break;
							}
							oneList.push(data.foodlist[n]);
						}
						$scope.pageFoodList.push(oneList);
					}
					$scope.foodList = $scope.pageFoodList[$scope.thisFoodPage - 1];
				} else {
					$scope.foodList = data.foodlist;
					$scope.foodPageNum = 1;
					$scope.thisFoodPage = 1;
				}
			}).error(function (err) {
				console.log(err);
			});

		}

		/*vip页面确定按钮*/
		$scope.changeVip = function () {
			if ($scope.showVipInfor == 2) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + 'cas/member/updateMember',
					data: {
						memberId: $scope.vipInfor.memberDo.objectSid,
						integral: $scope.changeIntegral,
						levelId: $scope.changeVipLevel.objectSid
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					if (data.message == 1) {
						$scope.vipInfor = data;
					}
					$ionicLoading.hide();
				}).error(function (err) {
					console.log(err);
				});
			} else if ($scope.showVipInfor == 1) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + 'cas/member/chargeMoney',
					data: {
						memberId: $scope.vipInfor.memberDo.objectSid,
						money: $scope.rechargeNum,
						restaurantId: $scope.myInfor.restaurantId
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					if (data.message == 1) {
						$scope.vipInfor = data;
						$scope.rechargeNum = "";
					}
					$ionicLoading.hide();
				}).error(function (err) {
					console.log(err);
				});
			} else if ($scope.showVipInfor == 3) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + 'cas/member/saveMember',
					data: {
						restaurantId: $scope.myInfor.restaurantId,
						name: $scope.newVipName,
						password: $scope.vipPassword,
						phone: $scope.newVipNum,
						balance: $scope.rechargeNum,
						levelId: $scope.changeVipLevel.objectSid
					},
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					if (data.message == 1) {
						$scope.vipInfor = data;
						$scope.haveVipCard = true;
						$scope.rechargeNum = "";
						$scope.newVipName = "";
						$scope.vipPassword = "";//会员密码
						$scope.newVipNum = "";
						$scope.changeVipLevel = "";
					}
					$ionicLoading.hide();
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*vip按钮按下*/
		$scope.vipNumAnxia = function ($event) {
			var thisNumBtn = $event.target;
			thisNumBtn.style.backgroundColor = "#00b667";
			thisNumBtn.style.color = "#ffffff";
			if (thisNumBtn.innerText == "清除") {
				$scope.vipCardNum = "";
			} else {
				$scope.vipCardNum += thisNumBtn.innerText;
			}
		}
		/*vip按钮放开*/
		$scope.vipNumfangkai = function ($event) {
			var par = $event.target.parentNode;
			var btns = par.children;
			for (var s = 0; s < btns.length; s++) {
				btns[s].style.backgroundColor = "#ffffff";
				btns[s].style.color = "#5c5c5c";
			}
			if (par.className == "number-btn") {
				btns[btns.length - 1].style.backgroundColor = "#00b667";
			}
		}
		/*点击登录*/
		$scope.goLogin = function () {
			//     	  console.log($scope.loginName);
			//     	  console.log($scope.loginPassword);  
			$scope.loginMsg = "";
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/login/check',
				data: { username: $scope.loginName, password: $scope.loginPassword },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				if (data.status == 0) {
					$scope.myInfor = data.data;
					$scope.getTablesList()
					$scope.isLogin = true;
					$scope.leftBtnList = data.vo;
					$scope.tuisong();
				} else {
					$scope.loginMsg = data.msg;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*登录技术支持*/
		$scope.showSupport = function () {
			$scope.showHidebg = true;
			$scope.showTechnicalSupport = true;
		}
		/*开台点餐*/
		$scope.OpenTableAndOrder = function () {

			var str = parseInt($scope.tableFoodNum).toString();
			if (str == "NaN" || str == '0') {
				layer.msg("请选择就餐人数")
				return
			}
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/desk/openTable',
				data: {
					restaurantId: $scope.myInfor.restaurantId, memberId: $scope.myInfor.objectSid, jobsId: $scope.waiterChoose.OBJECT_SID,
					seat: $scope.tableFoodNum, deskId: $scope.showTableInfor.OBJECT_SID, type: 1
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				if (data.message == 0) {
					$scope.hideAll();
					$scope.tableFoodNum = "";

					// $scope.getTablesList();
					$scope.foodCategory = 0;//菜单种类
					$scope.foodStartPrice = 0//开始价格
					$scope.foodEndPrice = 10000;//结束价格
					$scope.getFoodList();
					$scope.getTableInfor();
					$scope.getThisTableOrderList();
					$scope.showModule = 8;
				} else {
					layer.msg("当前餐台已经占,用请重新选择")
					// 关闭遮罩
					$scope.hideAll();
					// 重新获取餐厅信息
					$scope.getTablesList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*后台登录*/
		$scope.goBackLogin = function () {
			window.open("//www.jb51.net");
		}
		/*点菜*/
		$scope.chooseThisFood = function (index) {

			if (index.STATUS == 3) {
				return
			}
			console.log(index);
			$http({
				method: 'post',
				url: domainName + '/cas/order/addBillLine',
				data: {
					billId: $scope.showTableInfor.OBJECT_SID,
					foodId: index.OBJECT_SID,
					unit_price: index.UNIT_PRICE
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				if (data.code == 0) {
					$scope.getThisTableOrderList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*去点菜页面*/
		$scope.goToOrderFood = function () {
			if ($scope.canOrder) {
				$scope.showModule = 8;
				$scope.getFoodList();
				$scope.getThisTableOrderList();
			}
		}

		/*获取订单*/
		$scope.getThisTableOrderList = function () {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/order/getBillLineList',
				data: { bill_id: $scope.showTableInfor.OBJECT_SID },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				$scope.thisTableOrderInfor = data;
				//					   	   $scope.foodOrderList=data.flist;
				for (var i = 0; i < data.flist.length; i++) {
					if (data.flist[i].STATUS < 2) {
						$scope.canSettle = false;
						$scope.canSettleOne = false;
						break;
					}
					$scope.canSettle = true;
					memberId = true;
				}
				if (data.flist.length > 8) {
					$scope.pageFoodOrderList = [];
					$scope.foodOrderPageNum = Math.ceil(data.flist.length / 8);
					for (var m = 0; m < $scope.foodOrderPageNum; m++) {
						var oneList = []
						for (n = 8 * m; n < 8 * (m + 1); n++) {
							if (n > data.flist.length - 1) {
								break;
							}
							oneList.push(data.flist[n]);
						}
						$scope.pageFoodOrderList.push(oneList);
					}
					console.log($scope.pageFoodOrderList);
					$scope.foodOrderList = $scope.pageFoodOrderList[$scope.thisFoodOrderPage - 1];
				} else {
					$scope.foodOrderList = data.flist;
					$scope.foodOrderPageNum = 1;
					$scope.thisFoodOrderPage = 1;
				}
				$scope.chooseOrderFood = "";
			}).error(function (err) {
				console.log(err);
			});
		}
		$scope.closeRemark = function ($event) {
			$event.stopPropagation();
			$scope.hideAll();
		}
		/*选择备注*/
		$scope.remarkContent = "";//备注信息
		$scope.chooseThisRemark = function ($event, index) {
			if ($scope.remarkContent == "") {
				$scope.remarkContent = index;
			} else {
				$scope.remarkContent = $scope.remarkContent + "," + index;
			}
			$event.stopPropagation();
		}
		/*发送特殊备注*/
		$scope.sentSpecialRemark = function ($event) {
			$http({
				method: 'post',
				url: domainName + '/cas/order/updateOrderLine',
				data: { objectSid: $scope.chooseOrderFood.OBJECT_SID, description: $scope.remarkContent },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
					$scope.hideAll();
				}
			}).error(function (err) {
				console.log(err);
			});
			$event.stopPropagation();
		}
		/**
		 * 取消备注
		 */
		$scope.cancelRemarks = function () {
			// 取消菜的备注
			console.log("这是菜的id", $scope.chooseOrderFood.OBJECT_SID)
			console.log("这是订单的id：", $scope.thisTableOrderInfor.bill_id)
			if (parseFloat($scope.chooseOrderFood.OBJECT_SID).toString() != "NaN") {
				$http({
					method: 'post',
					url: domainName + '/cas/order/updateOrderLine',
					data: { objectSid: $scope.chooseOrderFood.OBJECT_SID, description: 'cancel' },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					if (data.msg == 0) {
						$scope.getThisTableOrderList();
						$scope.hideAll();
					}
				}).error(function (err) {
					console.log(err);
				});
				$event.stopPropagation();
				return
			} else {
				// 取消整单的备注
				$http({
					method: 'post',
					url: domainName + '/cas/order/updateOrderDescription',
					data: { objectSid: $scope.thisTableOrderInfor.bill_id, description: "cancel" },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					if (data.msg == 0) {
						$scope.getThisTableOrderList();
						$scope.hideAll();
					}
				}).error(function (err) {
					console.log(err);
				});
				$event.stopPropagation();

			}


		}
		/*发送备注*/
		$scope.sentRemark = function ($event) {
			$http({
				method: 'post',
				url: domainName + '/cas/order/updateOrderDescription',
				data: { objectSid: $scope.thisTableOrderInfor.bill_id, description: $scope.remarkContent },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
					$scope.hideAll();
				}
			}).error(function (err) {
				console.log(err);
			});
			$event.stopPropagation();
		}
		/*获取菜单*/
		$scope.getFoodList = function () {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/food/getDeskByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId, categoryId: $scope.foodCategory, aprice: $scope.foodStartPrice, bprice: $scope.foodEndPrice },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				$scope.foodCategorys = data.foodc;
				//					   	   $scope.foodList=data.foodlist;

				if (data.foodlist.length > 30) {
					$scope.pageFoodList = [];
					$scope.foodPageNum = Math.ceil(data.foodlist.length / 30);
					for (var m = 0; m < $scope.foodPageNum; m++) {
						var oneList = []
						for (n = 30 * m; n < 30 * (m + 1); n++) {
							if (n > data.foodlist.length - 1) {
								break;
							}
							oneList.push(data.foodlist[n]);
						}
						$scope.pageFoodList.push(oneList);
					}
					$scope.foodList = $scope.pageFoodList[$scope.thisFoodPage - 1];
				} else {
					$scope.foodList = data.foodlist;
					$scope.foodPageNum = 1;
					$scope.thisFoodPage = 1;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*只是开台*/
		$scope.onlyOpenTable = function () {
			var str = parseInt($scope.tableFoodNum).toString();
			if (str == "NaN" || str == '0') {
				layer.msg("请选择就餐人数")
				return
			}
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/desk/openTable',
				data: {
					restaurantId: $scope.myInfor.restaurantId,
					memberId: $scope.myInfor.objectSid,
					jobsId: $scope.waiterChoose.OBJECT_SID,
					seat: $scope.tableFoodNum,
					deskId: $scope.showTableInfor.OBJECT_SID,
					type: 1
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				if (data.message == 0) {
					$scope.hideAll();
					$scope.tableFoodNum = "";
					$scope.getTablesList();
				} else {
					layer.msg("当前餐台已经占,用请重新选择")
					// 关闭遮罩
					$scope.hideAll();
					// 重新获取餐厅
					$scope.getTablesList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*清台*/
		$scope.cleanThisTable = function () {
			if ($scope.clearTable) {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/desk/clearTable',
					data: { deskId: $scope.showTableInfor.OBJECT_SID, restaurantId: $scope.myInfor.restaurantId },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					$ionicLoading.hide();
					console.log(data);
					if (data.message == 0) {
						$scope.getTablesList();
						$scope.showTableInfor = "";
					}
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*书写就餐人数*/
		//    $scope.changeTablePeople=function(){
		//    	        if($scope.tableFoodNum>$scope.showTableInfor.seats){
		//      			$scope.tableFoodNum=$scope.showTableInfor.seats;
		//      		}
		//    }
		$scope.testAnxia = function () {
			console.log("按下");
		}
		$scope.testFangkai = function () {
			console.log("放开");
		}
		/*获取餐台信息*/
		$scope.getTablesList = function () {
			$scope.loginMsg = "";
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/desk/getDeskByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId, categoryId: $scope.tableArea, seats: $scope.tableSize, state: $scope.tableStatue },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$scope.allWaiter = data.jobs;
				$scope.waiterChoose = $scope.allWaiter[0];
				$ionicLoading.hide();
				$scope.categoryList = data.categorys;
				if (data.desks.length > 24) {
					$scope.pageTableList = [];
					$scope.tablePageNum = Math.ceil(data.desks.length / 20);
					for (var m = 0; m < $scope.tablePageNum; m++) {
						var oneList = []
						for (n = 24 * m; n < 24 * (m + 1); n++) {
							if (n > data.desks.length - 1) {
								break;
							}
							oneList.push(data.desks[n]);
						}
						$scope.pageTableList.push(oneList);
					}
					$scope.showTable = $scope.pageTableList[$scope.thistablePage - 1];
				} else {
					$scope.showTable = data.desks;
					$scope.pageTableList = false;
					$scope.tablePageNum = 1;
					$scope.thistablePage = 1;
				}
				$scope.showTableInfor = "";
				$scope.haveCheck = false;
				$scope.canOpen = false;
				$scope.canOrder = false;
				$scope.canSettleOne = false;
				$scope.clearTable = false;
				$scope.hetai = false;
			}).error(function (err) {
				console.log(err);
			});
		}
		/*结账预结*/
		$scope.toExpected = function () {
			if ($scope.canSettle && $scope.canSettleOne) {
				a($scope.chooseTableBill.OBJECT_SID);
				//    	  	$ionicLoading.show({
				//					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				//			     });
				//	        	 $http({  
				//				    method:'post',  
				//					url:domainName+'/cas/order/expected',  
				//					data:{desk_name:$scope.showTableInfor.NAME,billId:$scope.chooseTableBill.OBJECT_SID},
				//					headers:{ 'Content-Type': 'application/x-www-form-urlencoded'},
				//					transformRequest: function(obj) {    
				//					var str = [];    
				//					for (var s in obj) {    
				//						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));    
				//					}    
				//						return str.join("&");    
				//					}    
				//				   }).success(function(data){
				//				   	   $ionicLoading.hide(); 
				//				   	   console.log(data);
				//				   	   if(data.code==0){
				//				   	   	   a($scope.chooseTableBill.OBJECT_SID);
				//					   	   $ionicLoading.hide(); 
				//				   	   }
				//			        }).error(function(err) {
				//			         console.log(err);
				//		         });
			}

		}
		/*选择性别*/
		$scope.chooseSex = function (index) {
			$scope.thisSex = index;
		}
		/*餐台页面选择桌位大小*/
		$scope.chooseTableSize = function (index) {
			$scope.tableSize = index;
			$scope.getTablesList();
		}
		/*餐台页面选择桌位状态*/
		$scope.chooseTableStatus = function (index) {
			$scope.tableStatue = index;
			$scope.getTablesList();
		}
		/*餐台页面选择桌位区域*/
		$scope.chooseThisArea = function (index) {
			$scope.tableArea = index;
			$scope.getTablesList();
		}
		/*选择点菜种类*/
		$scope.chooseThisFoodCagegory = function (index) {
			$scope.foodCategory = index;
			$scope.getFoodList();
		}
		/*选择价格区域*/
		$scope.chooseThisFoodPrice = function (x, y) {
			$scope.foodStartPrice = x;
			$scope.foodEndPrice = y;
			$scope.getFoodList();
		}
		/*双击餐台进入点餐页面*/
		$scope.openTable = function (index) {
			$scope.showTableInfor = index;
			$scope.foodCategory = 0;//菜单种类
			$scope.foodStartPrice = 0//开始价格
			$scope.foodEndPrice = 10000;//结束价格
			if (index.current_state == 1) {
				var myDate = new Date();
				$scope.thisMonth = myDate.getMonth() + 1;
				$scope.thisDay = myDate.getDate();
				$scope.thisHour = myDate.getHours();
				$scope.thisHourMinutes = myDate.getMinutes();
				$scope.showHidebg = true;//弹窗遮罩
				$scope.showOpenTable = true;//开台弹窗
			} else if (index.current_state == 4) {//双击清台
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + '/cas/desk/clearTable',
					data: { deskId: $scope.showTableInfor.OBJECT_SID, restaurantId: $scope.myInfor.restaurantId },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					console.log(data);
					$ionicLoading.hide();
					if (data.message == 0) {
						$scope.getTablesList()
					}
				}).error(function (err) {
					console.log(err);
				});
			}
			else {
				$scope.getThisTableOrderList();
				$scope.getFoodList();
				$scope.getTableInfor();
				$scope.showModule = 8;
			}
		}
		/*关闭点餐页面回到餐台页面*/
		$scope.backLastPage = function (index) {
			$scope.showModule = index;
			if (index == 1) {
				$scope.getTablesList();
				$scope.showTableInfor = "";
				$scope.canSettle = false;
			} else if (index == 4) {
				$scope.getInventoryList();
			}
		}
		/*点击开台按钮进入点餐页面*/
		$scope.btnOpenTable = function () {
			if ($scope.canOpen) {
				$scope.showHidebg = true;//弹窗遮罩
				$scope.showOpenTable = true;//开台弹窗
				var myDate = new Date();
				$scope.thisMonth = myDate.getMonth() + 1;
				$scope.thisDay = myDate.getDate();
				$scope.thisHour = myDate.getHours();
				$scope.thisHourMinutes = myDate.getMinutes();
				//      		$scope.showModule=7;
			}

		}

		/*打开窗口之后点击窗口之外区域关闭窗口*/
		$scope.hideAll = function () {
			$scope.choosePay = 0;//选则支付方式
			$scope.choosePayName = "现金";//选则支付方式名字
			$scope.moneychange = 0;
			$scope.cashpay = "";
			$scope.cardpay = "";
			$scope.vippay = "";
			$scope.wxpay = "";
			$scope.zfbpay = "";
			$scope.combineTableShow = false;
			$scope.showOpenTips = false;
			$scope.settlePayNum = "";
			$scope.nowPayNum = Number($scope.settlePayNum);
			$scope.amountPaid = 0;
			$scope.tableFoodNum = "";
			$scope.showFastFoodSettleAccount = false;
			$scope.getBackNum = "";
			$scope.remarkContent = "";
			$scope.showEdit = false;
			$scope.listUpTableShow = false;
			$scope.settleHaveVip = false;
			$scope.settleAccountsPayNum = false;
			$scope.settleVipInfor = "";
			$scope.showHideVipbg = false;
			$scope.settleAccountsVipNum = false;
			$scope.showSettleAccount = false;
			$scope.showTechnicalSupport = false;
			$scope.showRequire = false;
			$scope.showHideBox = false;
			$scope.showRemark = false;
			$scope.presentFoodBox = false;
			$scope.returnDishes = false;
			$scope.changeStatus = false;
			$scope.callUp = false;
			$scope.foodChangeTable = false;
			$scope.changeTable = false;
			$scope.copyOrderShow = false;
			$scope.getBackFastFoodShow = false;
			$scope.showHidebg = false;//弹窗遮罩
			$scope.showOpenTable = false;//开台弹窗
			// 关闭估清
			$scope.estimate = false;
			$scope.cancelMuneArr = []
			$scope.unMuneIdArr = []


			var openTableOperatingContent = document.getElementsByClassName("fastFood-operating-content")[0];
			if (!openTableOperatingContent || !$scope.activateOperatingBtn && $scope.activateOperatingBtn != 0) {
				return;
			}
			openTableOperatingContent.children[$scope.activateOperatingBtn].style.backgroundColor = "";
		}
		/*点击展示编辑窗口*/
		$scope.showEditBox = function (index) {
			$scope.activateOperatingBtn = index;
			var openTableOperatingContent = document.getElementById("open-table-operating-content");
			openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
			console.log(openTableOperatingContent);
			$scope.showEdit = true;
			$scope.showHideBox = true;
		}
		/*餐台页面上一页*/
		$scope.tableLastPage = function () {
			if ($scope.thistablePage <= 1) {
				return;
			}
			$scope.thistablePage--;
			$scope.showTable = $scope.pageTableList[$scope.thistablePage - 1];
		}
		/*餐台页面下一页*/
		$scope.tableNextPage = function () {
			if ($scope.thistablePage >= $scope.tablePageNum) {
				return;
			}
			$scope.thistablePage++;
			$scope.showTable = $scope.pageTableList[$scope.thistablePage - 1];
		}
		/*订单列表上一页*/
		$scope.foodOrderLastPage = function () {
			if ($scope.thisFoodOrderPage <= 1) {
				return;
			}
			$scope.thisFoodOrderPage--;
			$scope.foodOrderList = $scope.pageFoodOrderList[$scope.thisFoodOrderPage - 1];
		}
		/*订单列表下一页*/
		$scope.foodOrderNextPage = function () {
			if ($scope.thisFoodOrderPage >= $scope.foodOrderPageNum) {
				return;
			}
			$scope.thisFoodOrderPage++;
			$scope.foodOrderList = $scope.pageFoodOrderList[$scope.thisFoodOrderPage - 1];
		}
		/*快餐订单列表上一页*/
		$scope.fastFoodOrderLastPage = function () {
			if ($scope.thisFastFoodOrderPage <= 1) {
				return;
			}
			$scope.thisFastFoodOrderPage--;
			$scope.fastFoodOrderList = $scope.pageFastFoodOrderList[$scope.thisFastFoodOrderPage - 1];
		}
		/*快餐订单页面下一页*/
		$scope.fastFoodOrderNextPage = function () {
			if ($scope.thisFastFoodOrderPage >= $scope.fastFoodOrderPageNum) {
				return;
			}
			$scope.thisFastFoodOrderPage++;
			$scope.fastFoodOrderList = $scope.pageFastFoodOrderList[$scope.thisFastFoodOrderPage - 1];
		}
		/*选择快餐订单行*/
		$scope.chooseThisFastFoodOrder = function (index) {
			$scope.chooseFastOrderFood = index;
			if ($scope.pageFastFoodOrderList) {
				for (var m = 0; m < $scope.pageFastFoodOrderList.length; m++) {
					for (var n = 0; n < $scope.pageFastFoodOrderList[m].length; n++) {
						if (index.lineSid == $scope.pageFastFoodOrderList[m][n].lineSid) {
							$scope.pageFastFoodOrderList[m][n].isCheck = true;
						} else {
							$scope.pageFastFoodOrderList[m][n].isCheck = false;
						}
					}
				}
			}
			for (var i = 0; i < $scope.fastFoodOrderList.length; i++) {
				if (index.lineSid == $scope.fastFoodOrderList[i].lineSid) {
					$scope.fastFoodOrderList[i].isCheck = true;
				} else {
					$scope.fastFoodOrderList[i].isCheck = false;
				}
			}
		}
		/*点击打开特殊要求*/
		$scope.showRequireBox = function (index) {
			$http({
				method: 'post',
				url: domainName + '/cas/order/listDcFabooDO',
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementById("open-table-operating-content");
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.showRequire = true;
					$scope.showHideBox = true;
					$scope.allRemark = data.date;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*点击打开备注按钮*/
		$scope.showRemarkBox = function (index) {
			$http({
				method: 'post',
				url: domainName + '/cas/order/listDcFabooDO',
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementById("open-table-operating-content");
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.showRemark = true;
					$scope.showHideBox = true;
					$scope.allRemark = data.date;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*点击打开赠菜按钮*/
		$scope.showPresentFood = function (index) {
			//      	$scope.activateOperatingBtn=index;
			//      	var openTableOperatingContent=document.getElementById("open-table-operating-content");
			//      	openTableOperatingContent.children[index].style.backgroundColor="#56a4e2";
			//      	$scope.presentFoodBox=true;
			//      	$scope.showHideBox=true;
			console.log($scope.chooseOrderFood);
			$http({
				method: 'post',
				url: domainName + '/cas/order/updateOrderLine',
				data: { objectSid: $scope.chooseOrderFood.OBJECT_SID, foodType: 1 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
					$scope.chooseOrderFood = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*点击打开退菜按钮*/
		$scope.showReturnDirshes = function (index) {
			//      	$scope.activateOperatingBtn=index;
			//      	var openTableOperatingContent=document.getElementById("open-table-operating-content");
			//      	openTableOperatingContent.children[index].style.backgroundColor="#56a4e2";
			//      	$scope.returnDishes=true;
			//      	$scope.showHideBox=true;
			console.log($scope.chooseOrderFood);
			$http({
				method: 'post',
				url: domainName + '/cas/order/retreatFoot',
				data: { objectSid: $scope.chooseOrderFood.OBJECT_SID },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
					$scope.chooseOrderFood = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*修改菜品状态*/
		$scope.changeFoodStatus = function ($event, index) {
			$scope.foodStatus = index;
			$scope.hideAll();
			$event.stopPropagation();
		}
		/*点击打开修改菜品状态页面*/
		$scope.showChangeStatus = function (index) {
			$scope.activateOperatingBtn = index;
			var openTableOperatingContent = document.getElementById("open-table-operating-content");
			openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
			$scope.changeStatus = true;
			$scope.showHideBox = true;
		}
		/*点击打开叫起窗口*/
		$scope.showCallUp = function (index) {
			$scope.activateOperatingBtn = index;
			var openTableOperatingContent = document.getElementById("open-table-operating-content");
			openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
			$scope.callUp = true;
			$scope.showHideBox = true;
		}
		/*选择叫起方式*/
		$scope.chooseCallUpStatus = function ($event, index) {
			$scope.callUpStatus = index;
			$scope.hideAll();
			$event.stopPropagation();
		}
		/*点击打开单品转菜按钮*/
		$scope.showFoodChangeTable = function (index) {
			//      	 console.log($scope.myInfor.restaurantId);
			$http({
				method: 'post',
				url: domainName + '/cas/desk/tableListByOrder',
				data: { objectSid: $scope.showTableInfor.OBJECT_SID, restaurantId: $scope.myInfor.restaurantId },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.allCanChangeTable = data.data;
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementById("open-table-operating-content");
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.foodChangeTable = true;
					$scope.showHideBox = true;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*删除订单中的食物*/
		$scope.delOrderFood = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/order/updateOrderLine',
				data: { objectSid: $scope.chooseOrderFood.OBJECT_SID, del: 1 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
					$scope.chooseOrderFood = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*点击打开转桌按钮*/
		$scope.showChangeTable = function (index) {
			$http({
				method: 'post',
				url: domainName + '/cas/desk/tableListByOrder',
				data: { objectSid: $scope.showTableInfor.OBJECT_SID, restaurantId: $scope.myInfor.restaurantId },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.allCanChangeTable = data.data;
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementById("open-table-operating-content");
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.changeTable = true;
					$scope.showHideBox = true;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*确定转桌*/
		$scope.toChangeTable = function ($event) {
			$event.stopPropagation();
			console.log($scope.changeFoodTable);
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/order/shiftTableList',
				data: { objectSid: $scope.thisTableOrderInfor.bill_id, tableId: $scope.changeFoodTable.OBJECT_SID, lodTable: $scope.showTableInfor.OBJECT_SID },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$ionicLoading.hide();
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
					$scope.hideAll();
					$scope.changeFoodTable = "";
					$scope.backLastPage(1);
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*点击打开复制整单按钮*/
		$scope.showCopyOrder = function (index) {
			$scope.getCopyTableList();
			$scope.activateOperatingBtn = index;
			var openTableOperatingContent = document.getElementById("open-table-operating-content");
			openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
			$scope.copyOrderShow = true;
			$scope.showHideBox = true;
		}
		/*获取复制整单所有餐台*/
		$scope.getCopyTableList = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/desk/getDeskByRestaurantId',
				data: { restaurantId: $scope.myInfor.restaurantId, categoryId: $scope.copyOrderTableArea, seats: $scope.copyOrderTableSize, state: 1 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.desks.length > 15) {
					$scope.pageCopyTableList = [];
					$scope.tableCopyPageNum = Math.ceil(data.desks.length / 15);
					for (var m = 0; m < $scope.tableCopyPageNum; m++) {
						var oneList = []
						for (n = 15 * m; n < 15 * (m + 1); n++) {
							if (n > data.desks.length - 1) {
								break;
							}
							oneList.push(data.desks[n]);
						}
						$scope.pageCopyTableList.push(oneList);
					}
					$scope.showCopyTable = $scope.pageCopyTableList[$scope.thisCopytablePage - 1];
				} else {
					$scope.pageCopyTableList = false;
					$scope.showCopyTable = data.desks;
					$scope.tableCopyPageNum = 1;
					$scope.thisCopytablePage = 1;
				}
				$scope.haveCheckCopy = false;
				console.log($scope.showCopyTable);
			}).error(function (err) {
				console.log(err);
			});
		}
		/*复制整单上一页*/
		$scope.copyOrderLastPage = function () {
			if ($scope.thisCopytablePage == 1) {
				return;
			} else {
				$scope.thisCopytablePage--;
				$scope.showCopyTable = $scope.pageCopyTableList[$scope.thisCopytablePage - 1];
			}
		}
		/*复制整单下一页*/
		$scope.copyOrderNextPage = function () {
			if ($scope.thisCopytablePage == $scope.tableCopyPageNum) {
				return;
			} else {
				$scope.thisCopytablePage++;
				$scope.showCopyTable = $scope.pageCopyTableList[$scope.thisCopytablePage - 1];
			}
		}
		/*选择复制的桌台*/
		$scope.chooseThisCopyTable = function (index) {
			$scope.checkCopyTables = []
			for (var i = 0; i < $scope.showCopyTable.length; i++) {
				if ($scope.showCopyTable[i].OBJECT_SID == index.OBJECT_SID) {
					$scope.showCopyTable[i].isCheck = !$scope.showCopyTable[i].isCheck;
				}
			}
			for (var s = 0; s < $scope.showCopyTable.length; s++) {
				if ($scope.showCopyTable[s].isCheck) {
					$scope.checkCopyTables.push($scope.showCopyTable[s]);
					$scope.haveCheckCopy = true;
				}
			}
		}
		/*确认复制整单*/
		$scope.toCopyTable = function ($event) {
			$event.stopPropagation();
			$scope.copyTablesId = "";
			for (var i = 0; i < $scope.checkCopyTables.length; i++) {
				if (i == 0) {
					$scope.copyTablesId = $scope.checkCopyTables[i].OBJECT_SID;
				} else {
					$scope.copyTablesId = $scope.copyTablesId + "," + $scope.checkCopyTables[i].OBJECT_SID;
				}
			}
			console.log($scope.copyTablesId);
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/order/copyTable',
				data: {
					objectSid: $scope.thisTableOrderInfor.bill_id,
					tableList: $scope.copyTablesId
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$ionicLoading.hide(0);
				if (data.msg == 0) {
					$scope.hideAll();
				}
				//		    	$scope.hideAll();
			}).error(function (err) {
				console.log(err);
			});
		}
		/*清除桌面订单*/
		$scope.clearTableOrderList = function () {
			console.log($scope.showTableInfor.OBJECT_SID);
			$http({
				method: 'post',
				url: domainName + '/cas/order/delOrderline',
				data: {
					bill_id: $scope.showTableInfor.OBJECT_SID,
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.code == 0) {
					$scope.getThisTableOrderList();
				}
				//		    	$scope.hideAll();
			}).error(function (err) {
				console.log(err);
			});
		}
		/*下单*/
		$scope.placeTheOrder = function () {
			b($scope.thisTableOrderInfor.bill_id);
			$http({
				method: 'post',
				url: domainName + '/cas/order/updateOrderSta',
				data: {
					bill_id: $scope.showTableInfor.OBJECT_SID
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.code == 0) {
					$scope.backLastPage(1);
				}
				//		    	$scope.hideAll();
			}).error(function (err) {
				console.log(err);
			});
		}
		/*快餐点菜*/
		$scope.chooseThisFastFood = function (index) {
			if (index.STATUS == 3) {
				return
			}
			$http({
				method: 'post',
				url: domainName + '/cas/snack/addSnackLine',
				data: {
					snackid: $scope.fastFoodOrderInfor.data.objectSid,
					foodId: index.OBJECT_SID,
					unitPrice: index.UNIT_PRICE
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.message == 0) {
					$scope.getFastFoodOrderList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*获取快餐菜单*/
		$scope.getFastFoodOrderList = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/snack/seeSnackLine',
				data: {
					snackId: $scope.fastFoodOrderInfor.data.objectSid,
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.message == 0) {
					$scope.fastFoodTitleNum = data.num;
					if (data.data.length > 8) {
						$scope.pageFastFoodOrderList = [];
						$scope.fastFoodOrderPageNum = Math.ceil(data.data.length / 8);
						for (var m = 0; m < $scope.fastFoodOrderPageNum; m++) {
							var oneList = []
							for (n = 8 * m; n < 8 * (m + 1); n++) {
								if (n > data.data.length - 1) {
									break;
								}
								oneList.push(data.data[n]);
							}
							$scope.pageFastFoodOrderList.push(oneList);
						}
						console.log($scope.pageFastFoodOrderList);
						$scope.fastFoodOrderList = $scope.pageFastFoodOrderList[$scope.thisFastFoodOrderPage - 1];
					} else {
						$scope.fastFoodOrderList = data.data;
						$scope.fastFoodOrderPageNum = 1;
						$scope.thisFoodOrderPage = 1;
					}
					$scope.chooseFastOrderFood = "";
				} else {
					$scope.fastFoodOrderList = "";
					$scope.chooseFastOrderFood = "";
					$scope.fastFoodTitleNum = false;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*删除一行快餐订单*/
		$scope.delOneFastFoodOrder = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/snack/updateSnackLine',
				data: {
					lineSid: $scope.chooseFastOrderFood.lineSid,
					del: 0
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getFastFoodOrderList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*整单复制选择桌位大小*/
		$scope.copyOrderChooseTableSize = function (index) {
			$scope.copyOrderTableSize = index;
			$scope.getCopyTableList();
		}
		/*整单复制选择桌位区域*/
		$scope.copyOrderChooseTableArea = function (index) {
			$scope.copyOrderTableArea = index;
			$scope.getCopyTableList();
		}
		/*打开快餐页面编辑窗口*/
		$scope.showFastFoodEdit = function (index) {
			$scope.activateOperatingBtn = index;
			var openTableOperatingContent = document.getElementsByClassName("fastFood-operating-content")[0];
			openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
			$scope.showEdit = true;
			$scope.showHideBox = true;
		}
		/*快餐页面特殊要求*/
		$scope.showFastFoodSpecialRequire = function (index) {
			$http({
				method: 'post',
				url: domainName + '/cas/order/listDcFabooDO',
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementsByClassName("fastFood-operating-content")[0];
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.showRequire = true;
					$scope.showHideBox = true;
					$scope.allRemark = data.date;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*发送快餐特殊要求*/
		$scope.sentFastFoodSpecialRemark = function ($event) {
			$event.stopPropagation();
			$http({
				method: 'post',
				url: domainName + '/cas/snack/updateSnackLine',
				data: {
					lineSid: $scope.chooseFastOrderFood.lineSid,
					description: $scope.remarkContent
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				if (data.msg == 0) {
					$scope.getFastFoodOrderList();
					$scope.hideAll();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*快餐页面备注窗口*/
		$scope.showFastFoodRemark = function (index) {
			$http({
				method: 'post',
				url: domainName + '/cas/order/listDcFabooDO',
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementsByClassName("fastFood-operating-content")[0];
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.showRemark = true;
					$scope.showHideBox = true;
					$scope.allRemark = data.date;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*清空快餐订单*/
		$scope.clearFastFoodOrder = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/snack/delSnackline',
				data: {
					snackId: $scope.fastFoodOrderInfor.data.objectSid
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.fastFoodOrderList = "";
					$scope.fastFoodTitleNum = false;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*发送快餐整单备注*/
		$scope.sentFastFoodRemark = function ($event) {
			$event.stopPropagation();
			$http({
				method: 'post',
				url: domainName + '/cas/snack/updateSnackDescription',
				data: {
					objectSid: $scope.fastFoodOrderInfor.data.objectSid,
					description: $scope.remarkContent
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				if (data.msg == 0) {
					$scope.getFastFoodOrderList();
					$scope.hideAll();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*快餐页面赠菜页面*/
		$scope.showFastFoodPresentFood = function () {
			console.log($scope.chooseFastOrderFood.lineSid);
			$http({
				method: 'post',
				url: domainName + '/cas/snack/updateSnackLine',
				data: { lineSid: $scope.chooseFastOrderFood.lineSid, foodType: 1 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getFastFoodOrderList();
					$scope.chooseOrderFood = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*保存快餐订单*/
		$scope.saveThisFastFoodOrder = function () {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/snack/saveSnackMark',
				data: { snackId: $scope.fastFoodOrderInfor.data.objectSid, mark: $scope.fastFoodOrderInfor.last },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$ionicLoading.hide()
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*快餐页面取回页面*/
		$scope.showFastFoodGetBack = function (index) {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/snack/snackMarkList',
				data: { restaurantId: $scope.myInfor.restaurantId, mark: "" },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$ionicLoading.hide();
				if (data.msg == 0) {
					$scope.activateOperatingBtn = index;
					var openTableOperatingContent = document.getElementsByClassName("fastFood-operating-content")[0];
					openTableOperatingContent.children[index].style.backgroundColor = "#56a4e2";
					$scope.getBackFastFoodShow = true;
					$scope.showHideBox = true;
					if (data.data.length > 7) {
						$scope.allPageFastFoodOrderList = [];
						$scope.allFastfoodOrderPageNum = Math.ceil(data.data.length / 7);
						for (var m = 0; m < $scope.allFastfoodOrderPageNum; m++) {
							var oneList = []
							for (n = 7 * m; n < 7 * (m + 1); n++) {
								if (n > data.data.length - 1) {
									break;
								}
								oneList.push(data.data[n]);
							}
							$scope.allPageFastFoodOrderList.push(oneList);
						}
						console.log($scope.allPageFastFoodOrderList);
						$scope.allShowFastfoodOrderList = $scope.allPageFastFoodOrderList[$scope.allThisFastFoodOrderPage - 1];
					} else {
						$scope.allShowFastfoodOrderList = data.data;
						$scope.allThisFastFoodOrderPage = 1;
						$scope.allFastfoodOrderPageNum = 1;
					}
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*获取取回列表*/
		$scope.getBackFastFoodOrder = function () {
			console.log($scope.getBackNum);
			$http({
				method: 'post',
				url: domainName + '/cas/snack/snackMarkList',
				data: { restaurantId: $scope.myInfor.restaurantId, mark: $scope.getBackNum },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					if (data.data.length > 7) {
						$scope.allPageFastFoodOrderList = [];
						$scope.allFastfoodOrderPageNum = Math.ceil(data.data.length / 7);
						for (var m = 0; m < $scope.allFastfoodOrderPageNum; m++) {
							var oneList = []
							for (n = 7 * m; n < 7 * (m + 1); n++) {
								if (n > data.data.length - 1) {
									break;
								}
								oneList.push(data.data[n]);
							}
							$scope.allPageFastFoodOrderList.push(oneList);
						}
						$scope.allShowFastfoodOrderList = $scope.allPageFastFoodOrderList[$scope.allThisFastFoodOrderPage - 1];
					} else {
						$scope.allShowFastfoodOrderList = data.data;
						$scope.allThisFastFoodOrderPage = 1;
						$scope.allFastfoodOrderPageNum = 1;
					}
					$scope.getBackNum = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*取回列表上一页*/
		$scope.getBackOrderListLastPage = function () {
			if ($scope.allThisFastFoodOrderPage == 1) {
				return;
			}
			$scope.allThisFastFoodOrderPage--;
			$scope.allShowFastfoodOrderList = $scope.allPageFastFoodOrderList[$scope.allThisFastFoodOrderPage - 1];
		}
		/*取回列表下一页*/
		$scope.getBackOrderListNextPage = function () {
			if ($scope.allThisFastFoodOrderPage >= $scope.allFastfoodOrderPageNum) {
				return;
			}
			$scope.allThisFastFoodOrderPage++;
			$scope.allShowFastfoodOrderList = $scope.allPageFastFoodOrderList[$scope.allThisFastFoodOrderPage - 1];
		}
		/*选择这个取回*/
		$scope.chooseThisGetBack = function (index) {
			$scope.chooseGetBackOrder = index;
			if ($scope.allPageFastFoodOrderList) {
				for (var m = 0; m < $scope.allPageFastFoodOrderList.length; m++) {
					for (var n = 0; n < $scope.allPageFastFoodOrderList[m].length; n++) {
						if (index.OBJECT_SID == $scope.allPageFastFoodOrderList[m][n].OBJECT_SID) {
							$scope.allPageFastFoodOrderList[m][n].isCheck = true;
						} else {
							$scope.allPageFastFoodOrderList[m][n].isCheck = false;
						}
					}
				}
			}
			for (var i = 0; i < $scope.allShowFastfoodOrderList.length; i++) {
				if (index.OBJECT_SID == $scope.allShowFastfoodOrderList[i].OBJECT_SID) {
					$scope.allShowFastfoodOrderList[i].isCheck = true;
				} else {
					$scope.allShowFastfoodOrderList[i].isCheck = false;
				}
			}
		}
		/*确定取回*/
		$scope.getBackThisFastFoodOrder = function () {
			if (!$scope.chooseGetBackOrder) {
				return;
			}
			$scope.fastFoodOrderInfor.data.objectSid = $scope.chooseGetBackOrder.OBJECT_SID;
			$scope.fastFoodOrderInfor.data.snackCode = $scope.chooseGetBackOrder.SNACK_CODE;
			$scope.fastFoodOrderInfor.last = $scope.chooseGetBackOrder.MARK;
			$scope.getFastFoodOrderList();
			$scope.hideAll();
			$scope.chooseGetBackOrder = "";
		}
		/*快餐下单*/
		$scope.fastFoodPlaceOrder = function () {
			console.log($scope.fastFoodOrderInfor.data.objectSid);
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + '/cas/snack/palceSnack',
				data: { snackId: $scope.fastFoodOrderInfor.data.objectSid },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.addFastFood();
					$ionicLoading.hide();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*新建快餐*/
		$scope.addFastFood = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/snack/createSnack',
				data: { restaurantId: $scope.myInfor.restaurantId, type: 1 },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.message == 0) {
					$ionicLoading.hide();
					$scope.fastFoodOrderInfor = data;
					$scope.fastFoodTitleNum = false;
					$scope.chooseFastOrderFood = "";
					$scope.fastFoodOrderList = [];
					$scope.foodCategory = 0;//菜单种类
					$scope.foodStartPrice = 0//开始价格
					$scope.foodEndPrice = 10000;//结束价格
					$scope.getFoodList();
				}

			}).error(function (err) {
				console.log(err);
			});
		}
		/*删除取回列表*/
		$scope.delThisFastFoodOrder = function () {
			if (!$scope.chooseGetBackOrder) {
				return;
			}
			$http({
				method: 'post',
				url: domainName + '/cas/snack/delSnackMark',
				data: { snackId: $scope.chooseGetBackOrder.OBJECT_SID },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getBackFastFoodOrder();
					$scope.chooseGetBackOrder = "";
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*编辑窗口键盘按下后变色*/
		$scope.anxia = function (a, b) {
			var foodNumKeyboard = document.getElementsByClassName("foodNumKeyboard")[0].children;
			foodNumKeyboard[a].style.backgroundColor = "#00b667";
			foodNumKeyboard[a].children[0].style.color = "#FFFFFF";
			if (b == "close") {
				$scope.tableFoodNum = "";
			} else if (b == "clear") {
				$scope.tableFoodNum = $scope.tableFoodNum.substring(0, $scope.tableFoodNum.length - 1);
			} else if (b == "ok") {
				if ($scope.tableFoodNum == "") {
					return
				} else if ($scope.showModule == 8) {
					$http({
						method: 'post',
						url: domainName + '/cas/order/updateOrderLine',
						data: { objectSid: $scope.chooseOrderFood.OBJECT_SID, foodNum: $scope.tableFoodNum },
						headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
						transformRequest: function (obj) {
							var str = [];
							for (var s in obj) {
								str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
							}
							return str.join("&");
						}
					}).success(function (data) {
						console.log(data);
						if (data.msg == 0) {
							$scope.getThisTableOrderList();
							$scope.hideAll();
						}
					}).error(function (err) {
						console.log(err);
					});
				} else if ($scope.showModule == 2) {
					$http({
						method: 'post',
						url: domainName + '/cas/snack/updateSnackLine',
						data: { lineSid: $scope.chooseFastOrderFood.lineSid, foodNum: $scope.tableFoodNum },
						headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
						transformRequest: function (obj) {
							var str = [];
							for (var s in obj) {
								str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
							}
							return str.join("&");
						}
					}).success(function (data) {
						console.log(data);
						if (data.msg == 0) {
							$scope.getFastFoodOrderList();
							$scope.hideAll();
						}
					}).error(function (err) {
						console.log(err);
					});
				}
			} else {
				$scope.tableFoodNum += b;
			}
			if ($scope.showOpenTable) {

			}
			if ($scope.showEdit) {
				if ($scope.tableFoodNum > 100) {
					$scope.tableFoodNum = 100;
				}
			}
		}
		/*菜单上一页*/
		$scope.lastFoodPage = function () {
			if ($scope.thisFoodPage == 1) {
				return;
			}
			$scope.thisFoodPage--;
			$scope.foodList = $scope.pageFoodList[$scope.thisFoodPage - 1];
		}
		/*菜单下一页*/
		$scope.nextFoodPage = function () {
			if ($scope.thisFoodPage == $scope.foodPageNum) {
				return;
			}
			$scope.thisFoodPage++;
			$scope.foodList = $scope.pageFoodList[$scope.thisFoodPage - 1];
		}
		/*加减订单食物份数*/
		$scope.changeOrderFood = function ($event, index, x) {
			var count = 0
			if (index == 1) {
				layer.prompt({ title: '输入取消的份数，并确认', formType: 0 }, function (pass, ew) {
					var str = parseInt(pass).toString()
					if (str == "NaN") {
						layer.msg("请输入整数")
						return
					}
					count = parseInt(pass)
					$scope.changeOrderFoodHttp($event, x, index, count);
					// 关闭
					layer.close(ew);
				});
			} else {
				$scope.changeOrderFoodHttp($event, x, index, count);
			}


		}
		$scope.changeOrderFoodHttp = function ($event, x, index, count) {
			$event.stopPropagation();
			$http({
				method: 'post',
				url: domainName + '/cas/order/updateOrderLine',
				data: {
					objectSid: x,
					param: index,
					count: count,
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getThisTableOrderList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}

		/*排队页面开桌*/
		$scope.listUpToOpentable = function (index) {
			$scope.toOpenLineUpList = index;
			$scope.getCopyTableList();
			$scope.listUpTableShow = true;
			$scope.showHideBox = true;
		}
		/*排队页面开台*/
		$scope.listUpOpenTable = function () {
			console.log($scope.toOpenLineUpList);
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + 'cas/queue/openTable',
				data: {
					restaurantId: $scope.myInfor.restaurantId, memberId: $scope.myInfor.objectSid,
					seat: $scope.toOpenLineUpList.SIZE, deskId: $scope.toOpenThisLineUpTable.OBJECT_SID,
					type: 1, objectSid: $scope.toOpenLineUpList.OBJECT_SID
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				if (data.message == 0) {
					$scope.hideAll();
					$scope.getLineUpList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*排队页面开台并点餐*/
		$scope.listUpOpenTableAndOrder = function () {

			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + 'cas/queue/openTable',
				data: {
					restaurantId: $scope.myInfor.restaurantId, memberId: $scope.myInfor.objectSid,
					seat: $scope.toOpenLineUpList.SIZE, deskId: $scope.toOpenThisLineUpTable.OBJECT_SID,
					type: 1, objectSid: $scope.toOpenLineUpList.OBJECT_SID
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				if (data.message == 0) {
					$scope.hideAll();
					$scope.showTableInfor = $scope.toOpenThisLineUpTable;
					$scope.getThisTableOrderList();
					$scope.getFoodList();
					$scope.getTableInfor();
					$scope.showModule = 8;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*排队叫号*/
		$scope.lineUPCallUp = function (index) {
			console.log(index);
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + 'cas/queue/updateCasQueue',
				data: { objectSid: index.OBJECT_SID, status: index.SATAUS },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				$ionicLoading.hide();
				console.log(data);
				$scope.getLineUpList();
			}).error(function (err) {
				console.log(err);
			});
		}
		/*切换书写区域*/
		$scope.toWriteThis = function (index) {
			$scope.lineUpIsPersonNum = index;
		}
		/*排队选桌点击桌面*/
		$scope.lineUpchooseThisTable = function (index) {
			$scope.toOpenThisLineUpTable = index;
			if ($scope.pageCopyTableList) {
				for (var m = 0; m < $scope.pageCopyTableList.length; m++) {
					for (var n = 0; n < $scope.pageCopyTableList[m].length; n++) {
						$scope.pageCopyTableList[m][n].isCheck = false;
					}
				}
			} else {
				for (var s = 0; s < $scope.showCopyTable.length; s++) {
					$scope.showCopyTable[s].isCheck = false;
				}
			}
			for (var i = 0; i < $scope.showCopyTable.length; i++) {
				if ($scope.showCopyTable[i].OBJECT_SID == index.OBJECT_SID) {
					$scope.showCopyTable[i].isCheck = true;
				}
			}
		}
		/*排队取号*/
		$scope.takeNumber = function () {
			if ($scope.lineUpPersonNum != "" && $scope.lineUpTelNum != "") {
				$ionicLoading.show({
					template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
				});
				$http({
					method: 'post',
					url: domainName + 'cas/queue/addCasQueue',
					data: { restaurantId: $scope.myInfor.restaurantId, phone: $scope.lineUpTelNum, seats: $scope.lineUpPersonNum },
					headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
					transformRequest: function (obj) {
						var str = [];
						for (var s in obj) {
							str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
						}
						return str.join("&");
					}
				}).success(function (data) {
					$ionicLoading.hide();
					console.log(data);
					if (data.status == 1) {
						$scope.lineUpTelNum = "";
						$scope.lineUpPersonNum = "";
						$scope.chooseLineUpSize = 0;
						$scope.lineUpseats = "";
						$scope.getLineUpList();
					}
				}).error(function (err) {
					console.log(err);
				});
			}
		}
		/*显示所有排队列表*/
		$scope.showAllStetes = function () {
			$scope.chooseLineUpSize = 0;
			$scope.lineUpseats = "";
			$scope.getLineUpList();
		}
		/*选择人数显示列表*/
		$scope.chooseThisSteats = function (index) {
			$scope.chooseLineUpSize = index.OBJECT_SID;
			$scope.lineUpseats = index.SEQ;
			$scope.getLineUpList();
		}
		/*获取排队列表*/
		$scope.getLineUpList = function () {
			$ionicLoading.show({
				template: '<ion-spinner icon="ios" class="spinner-light"></ion-spinner>'
			});
			$http({
				method: 'post',
				url: domainName + 'cas/queue/casQueueListByRestId',
				data: { restaurantId: $scope.myInfor.restaurantId, seats: $scope.lineUpseats },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$ionicLoading.hide();
				$scope.allThisLineUpPage = 1;
				$scope.allLineUpCatecory = data.seatsList;
				if (data.seccpQueueList.length > 7) {
					$scope.allPageLineUpList = [];
					$scope.allLineUpPageNum = Math.ceil(data.seccpQueueList.length / 7);
					for (var m = 0; m < $scope.allLineUpPageNum; m++) {
						var oneList = []
						for (n = 7 * m; n < 7 * (m + 1); n++) {
							if (n > data.seccpQueueList.length - 1) {
								break;
							}
							oneList.push(data.seccpQueueList[n]);
						}
						$scope.allPageLineUpList.push(oneList);
					}
					console.log($scope.allPageLineUpList);
					$scope.allLineUpList = $scope.allPageLineUpList[$scope.allThisLineUpPage - 1];
				} else {
					$scope.allLineUpList = data.seccpQueueList;
					$scope.allThisLineUpPage = 1;
					$scope.allLineUpPageNum = 1;
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*排队上一页*/
		$scope.lineUpLastPage = function () {
			if ($scope.allThisLineUpPage == 1) {
				return;
			}
			$scope.allThisLineUpPage--;
			$scope.allLineUpList = $scope.allPageLineUpList[$scope.allThisLineUpPage - 1];
		}
		/*排队下一页*/
		$scope.lineUpNextPage = function () {
			if ($scope.allThisLineUpPage == $scope.allLineUpPageNum) {
				return;
			}
			$scope.allThisLineUpPage++;
			$scope.allLineUpList = $scope.allPageLineUpList[$scope.allThisLineUpPage - 1];
		}
		/*排队页面叫号键盘按下*/
		$scope.lineUpanxia = function (a, b) {
			var foodNumKeyboard = document.getElementsByClassName("lineUpfoodNumKeyboard")[0].children;
			foodNumKeyboard[a].style.backgroundColor = "#00b667";
			foodNumKeyboard[a].children[0].style.color = "#FFFFFF";
			if ($scope.lineUpIsPersonNum == 1) {
				if (b == "close") {
					$scope.lineUpPersonNum = "";
				} else if (b == "clear") {
					$scope.lineUpPersonNum = $scope.lineUpPersonNum.substring(0, $scope.lineUpPersonNum.length - 1);
				} else {
					$scope.lineUpPersonNum += b;
				}
			} else if ($scope.lineUpIsPersonNum == 2) {
				if (b == "close") {
					$scope.lineUpTelNum = "";
				} else if (b == "clear") {
					$scope.lineUpTelNum = $scope.lineUpTelNum.substring(0, $scope.lineUpTelNum.length - 1);
				} else {
					$scope.lineUpTelNum += b;
				}
			}

		}
		/*排队页面叫号键盘放开*/
		$scope.lineUpfangkai = function () {
			var foodNumKeyboard = document.getElementsByClassName("lineUpfoodNumKeyboard")[0].children;
			for (var s = 0; s < foodNumKeyboard.length; s++) {
				foodNumKeyboard[s].style.backgroundColor = "#e6e7ea";
				foodNumKeyboard[s].children[0].style.color = "#5c5c5c";
			}
		}
		/*加减快餐订单食物数量*/
		$scope.changeOrderFastFood = function ($event, index, x) {
			console.log(index);
			console.log(x);
			$event.stopPropagation();
			$http({
				method: 'post',
				url: domainName + '/cas/snack/updateSnackLine',
				data: { lineSid: x, param: index },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				if (data.msg == 0) {
					$scope.getFastFoodOrderList();
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*选择订单中的一个菜品*/
		$scope.chooseThisOrderFood = function (index) {
			$scope.chooseOrderFood = index;
			if ($scope.pageFoodOrderList) {
				for (var m = 0; m < $scope.pageFoodOrderList.length; m++) {
					for (var n = 0; n < $scope.pageFoodOrderList[m].length; n++) {
						;
						$scope.pageFoodOrderList[m][n].isCheck = false;
					}
				}
			}
			for (var i = 0; i < $scope.foodOrderList.length; i++) {
				if (index.OBJECT_SID == $scope.foodOrderList[i].OBJECT_SID) {
					$scope.foodOrderList[i].isCheck = true;
				} else {
					$scope.foodOrderList[i].isCheck = false;
				}
			}

		}
		/*编辑窗口键盘放开后恢复颜色*/
		$scope.fangkai = function () {
			var foodNumKeyboard = document.getElementsByClassName("foodNumKeyboard")[0].children;
			for (var s = 0; s < foodNumKeyboard.length; s++) {
				foodNumKeyboard[s].style.backgroundColor = "#e6e7ea";
				foodNumKeyboard[s].children[0].style.color = "#5c5c5c";
			}
		}
		/*搜索菜单键盘按下变色*/
		$scope.keyAnxia = function (a, b) {
			var foodMuneKeyboard = document.getElementsByClassName("keys")[0].children;
			foodMuneKeyboard[a].style.backgroundColor = "#00b667";
			foodMuneKeyboard[a].children[0].style.color = "#FFFFFF";

			// 改变简码
			if (b == 'clear') {
				// 清除事件
				$scope.jm = "";
			} else if (b == 'del') {
				// 删除事件
				$scope.jm = $scope.jm.substr(0, $scope.jm.length - 1);
			} else if (b == '后退') {
				// 后退事件
			} else if (b == '后退') {
				// 后退事件
			} else if (b == '前进') {
				// 后退事件
			} else {
				if ($scope.jm.length > 10) {
					layer.msg('长度超出限制');
				} else {
					$scope.jm = $scope.jm + b;
				}
			}



		}
		/*搜索菜单键盘松开恢复*/
		$scope.keyFangkai = function () {
			var foodMuneKeyboard = document.getElementsByClassName("keys")[0].children;
			for (var s = 0; s < foodMuneKeyboard.length; s++) {
				foodMuneKeyboard[s].style.backgroundColor = "#ffffff";
				foodMuneKeyboard[s].children[0].style.color = "#333333";
			}
			foodMuneKeyboard[foodMuneKeyboard.length - 1].style.backgroundColor = "#00b667";
			foodMuneKeyboard[foodMuneKeyboard.length - 1].children[0].style.color = "#FFFFFF";

		}
		/**
		 * 获取光标的位置
		 */
		function getTxt1CursorPosition(id) {
			var oTxt1 = document.getElementById(id);
			var cursurPosition = -1;
			if (oTxt1.selectionStart) {//非IE浏览器
				cursurPosition = oTxt1.selectionStart;
			} else {//IE
				var range = document.selection.createRange();
				range.moveStart("character", -oTxt1.value.length);
				cursurPosition = range.text.length;
			}
		}

		/*改变搜索食物方式*/
		$scope.chooseFoodSearchMode = function (index) {
			$scope.foodSearchMode = index;
		}
		/*获取桌面信息*/
		$scope.getTableInfor = function () {
			$http({
				method: 'post',
				url: domainName + '/cas/desk/getDeskInfo',
				data: { deskId: $scope.showTableInfor.OBJECT_SID },
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$scope.chooseTableInfor = data.deskInfo[0];
				if ($scope.showTableInfor.current_state == 3) {
					$scope.chooseTableInfor = data.deskInfo[0];
					$scope.chooseTableBill = data.bill[0];
					for (var i = 0; i < data.lines.length; i++) {
						if (data.lines[i].STATUS < 2) {
							$scope.canSettle = false;
							break;
						}
						$scope.canSettle = true;
					}
					if (data.lines.length > 9) {
						$scope.pageTableOrderList = [];
						$scope.tableOrderPageNum = Math.ceil(data.lines.length / 9);
						for (var m = 0; m < $scope.tableOrderPageNum; m++) {
							var oneList = []
							for (n = 9 * m; n < 9 * (m + 1); n++) {
								if (n > data.lines.length - 1) {
									break;
								}
								oneList.push(data.lines[n]);
							}
							$scope.pageTableOrderList.push(oneList);
						}
						console.log($scope.pageTableOrderList);
						$scope.tableOrderList = $scope.pageTableOrderList[$scope.tableOrderPage - 1];
					} else {
						$scope.tableOrderList = data.lines;
						$scope.tableOrderPage = 1;
						$scope.tableOrderPageNum = 1;
					}
				}
			}).error(function (err) {
				console.log(err);
			});
		}
		/*桌面显示订单上一页*/
		$scope.tableOrderListLastPage = function () {
			if ($scope.tableOrderPage == 1) {
				return;
			}
			$scope.tableOrderPage--;
			$scope.tableOrderList = $scope.pageTableOrderList[$scope.tableOrderPage - 1];
		}
		/*桌面显示订单下一页*/
		$scope.tableOrderListNextPage = function () {
			if ($scope.tableOrderPage >= $scope.tableOrderPageNum) {
				return;
			}
			$scope.tableOrderPage++;
			$scope.tableOrderList = $scope.pageTableOrderList[$scope.tableOrderPage - 1];
		}
		$scope.setBlur = function () {
			$scope.isCome = true;
			$scope.isFocus = true;
		}
		$scope.showMune = function () {
			$scope.showHidebg = true;
			$scope.estimate = true;
			$ionicLoading.hide();
			$scope.getFoodList();
		}
		/*点击获得菜单id */
		$scope.getGoodsId = function (goods, state) {
			if (goods.isCheck) {
				return
			}

			goods['isCheck'] = true

			if (state == 0) {
				$scope.unMuneIdArr.push(goods.OBJECT_SID)
			} else {
				$scope.cancelMuneArr.push(goods.OBJECT_SID)
			}
		}
		/*确定估清产品 */
		$scope.sendGoodsId = function () {
			if ($scope.unMuneIdArr.length == 0) {
				layer.msg("请选择估清的产品")
				return
			}
			$http({
				method: 'post',
				url: domainName + '/cas/snack/estimate',
				data: {
					objectSids: $scope.unMuneIdArr
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$scope.estimate = false
				$scope.showHidebg = false;
				$scope.unMuneIdArr = []
			}).error(function (err) {
				console.log(err);
			});
		}
		/*取消估清产品 */
		$scope.clearMune = function () {
			if ($scope.cancelMuneArr.length == 0) {
				layer.msg("请选择取消估清的产品")
				return
			}
			$http({
				method: 'post',
				url: domainName + '/cas/snack/cancelEstimate',
				data: {
					objectSids: $scope.cancelMuneArr
				},
				headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
				transformRequest: function (obj) {
					var str = [];
					for (var s in obj) {
						str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
					}
					return str.join("&");
				}
			}).success(function (data) {
				console.log(data);
				$scope.estimate = false;
				$scope.showHidebg = false;
				$scope.cancelMuneArr = []
			}).error(function (err) {
				console.log(err);
			});
		}
		/**
		 * 关闭估清
		 */
		$scope.closeMune = function () {
			$scope.estimate = false;
			$scope.showHidebg = false;
			$scope.cancelMuneArr = []
			$scope.unMuneIdArr = []
		}


		/**
		 * 提示层信息
		 */
		// 撤单
		$scope.toCancellations = function () {
			if ($scope.canSettle && $scope.canSettleOne) {
				// 弹窗遮罩
				$scope.showHidebg = true;
				// 提示弹窗
				$scope.showOpenTips = true;
				$scope.tipContent = "确定撤单？";

			}
		}
		// 提示层 自动关闭
		$scope.selectGoods = function (msg) {
			setTimeout(() => {
				if (hidebg) {
					$scope.showHidebg = false;//弹窗遮罩
				}
				$scope.showOpenTips = false;

			}, 2 * 1000)
		}
		/*点击餐台出现选择状态，根据餐台的不同状态出现不同按钮状态*/
		$scope.chooseThisTable = function (index) {
			if ($scope.pageTableList) {
				for (var m = 0; m < $scope.pageTableList.length; m++) {
					for (var n = 0; n < $scope.pageTableList[m].length; n++) {
						$scope.pageTableList[m][n].isCheck = false;
					}
				}
			}
			for (var i = 0; i < $scope.showTable.length; i++) {
				if ($scope.showTable[i].OBJECT_SID == index.OBJECT_SID) {
					$scope.showTable[i].isCheck = true;
					$scope.showTableInfor = $scope.showTable[i];
				} else {
					$scope.showTable[i].isCheck = false;
				}
			}
			$scope.haveCheck = true;
			$scope.getTableInfor();
			$scope.canOpen = false;//可以开台
			$scope.canOrder = false;//可以点餐
			$scope.canSettleOne = false;//可以结账
			$scope.clearTable = false;
			$scope.hetai = false;
			if ($scope.showTableInfor.current_state == 1) {
				$scope.canOpen = true;
			} else if ($scope.showTableInfor.current_state == 3) {
				$scope.canOrder = true;
				$scope.canSettleOne = true;
				$scope.hetai = true;
			} else if ($scope.showTableInfor.current_state == 2 || $scope.showTableInfor.tableStatus == 3) {
				$scope.canOrder = true;
				$scope.clearTable = true;
			} else if ($scope.showTableInfor.current_state == 4) {
				$scope.clearTable = true;
			}
		}
	}])
	.directive('onFinishRenderFilters', function ($timeout) {
		return {
			link: function (scope, element, attr) {
				if (scope.$last == true) {
					$timeout(function () {
						scope.$emit('ngRepeatFinished');
					});
				}
			}
		}
	})
	.directive('sglclick', ['$parse', function ($parse) {
		return {
			restrict: 'A',
			link: function (scope, element, attr) {
				var fn = $parse(attr['sglclick']);
				var delay = 400, clicks = 0, timer = null;
				element.on('click', function (event) {
					clicks++;  //count clicks
					if (clicks === 1) {
						timer = setTimeout(function () {
							scope.$apply(function () {
								fn(scope, { $event: event });
							});
							clicks = 0;
						}, delay);
					} else {
						clearTimeout(timer);
						clicks = 0;
					}
				});
			}
		};
	}])
	.directive("ngTouchstart", function () {
		return {
			controller: ["$scope", "$element", function ($scope, $element) {

				$element.bind("touchstart", onTouchStart);
				function onTouchStart(event) {
					var method = $element.attr("ng-touchstart");
					$scope.$apply(method);
				}

			}]
		}
	})
	.directive("ngTouchmove", function () {
		return {
			controller: ["$scope", "$element", function ($scope, $element) {

				$element.bind("touchstart", onTouchStart);
				function onTouchStart(event) {
					event.preventDefault();
					$element.bind("touchmove", onTouchMove);
					$element.bind("touchend", onTouchEnd);
				}
				function onTouchMove(event) {
					var method = $element.attr("ng-touchmove");
					$scope.$apply(method);
				}
				function onTouchEnd(event) {
					event.preventDefault();
					$element.unbind("touchmove", onTouchMove);
					$element.unbind("touchend", onTouchEnd);
				}

			}]
		}
	})
	.directive("ngTouchend", function () {
		return {
			controller: ["$scope", "$element", function ($scope, $element) {

				$element.bind("touchend", onTouchEnd);
				function onTouchEnd(event) {
					var method = $element.attr("ng-touchend");
					$scope.$apply(method);
				}

			}]
		}
	})
	.directive('setFocus', [function () {
		return {
			scope: false,
			link: function (scope, element) {
				scope.$watch("isFocus", function (newValue, oldValue, scope) {
					if (newValue && scope.isCome) {
						element[0].focus();
					}
				}, true);
			}
		};
	}]);

function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]); return null;
}
function diaoyong() {
	console.log($("#startDate").val());
}
function a(s) {
	$.ajax({
		url: domainName + "cas/print/get58PrintData",
		type: "post",
		data: {
			'billId': s
		},
		success: function (data) {
			console.log(data);
			print(data);
		}
	});
}
function c(s) {
	$.ajax({
		url: domainName + "cas/print/get58PrintHisData",
		type: "post",
		data: {
			'billCode': s
		},
		success: function (data) {
			console.log(data);
			printC(data);
		}
	});
}
function b(x) {
	$.ajax({
		url: domainName + "/cas/print/get80PrintData",
		type: "post",
		data: {
			'billId': x
		},
		success: function (data) {
			console.log(data);
			printB(data);
		}
	});
}
function fastFoodA(x) {
	$.ajax({
		url: domainName + "cas/print/getSnack58PrintHisData",
		type: "post",
		data: {
			'snackCode': x
		},
		success: function (data) {
			console.log(data);
			print(data);
		}
	});
}
function fastFoodB(x) {
	$.ajax({
		url: domainName + "cas/print/getSnack80PrintHisData",
		type: "post",
		data: {
			'snackCode': x
		},
		success: function (data) {
			console.log(data);
			printB(data);
		}
	});
}
//
function printB(data) {
	var DriverName = "(AO)Client-Bridge Driver"; //驱动名称
	var BridgeIDandName; //端桥表示;端桥名称
	var printerName; 	 //打印机名称
	var strPageSizeName = "Gprinter 80(72.1) x 297 mm";

	for (var i in data.lines) {
		var index = 1; //序号

		LODOP.SET_PRINT_PAGESIZE(3, 800, 0, 0);//设置纸张大小
		// LODOP.ADD_PRINT_TEXT(20, 60, 145, 35, "后厨点单");
		// LODOP.SET_PRINT_STYLEA(0, "FontSize", 17);
		// LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);

		LODOP.ADD_PRINT_TEXT(0, 15, 175, 14, data.deskNo);
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
		LODOP.ADD_PRINT_TEXT(20, 15, 230, 10, "单号:" + data.orderNo);
		//LODOP.ADD_PRINT_TEXT(120, 15, 155, 25, "开单时间：" + data.createBillDate);
		//LODOP.ADD_PRINT_TEXT(150, 15, 105, 25, "就餐人数：" + data.seat);
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);

		//品名上划线
		LODOP.ADD_PRINT_LINE(37, 15, 37, 250, 0, 1);

		LODOP.ADD_PRINT_TEXT(39, 15, 150, 20, "品名");
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
		LODOP.ADD_PRINT_TEXT(39, 150, 50, 20, "数量");
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
		LODOP.ADD_PRINT_TEXT(39, 210, 40, 20, "单位");
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
		LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
		//品名下划线
		LODOP.ADD_PRINT_LINE(58, 16, 58, 250, 0, 1);
		var str = data.lines;
		var h = 0; //备注占的高度
		var linHight = 20; //行高
		for (var j in data.lines[i]) {
			//菜名
			var name = data.lines[i][j].FOOTNAME;
			if (name.length > 8) {
				name = name.substring(0, 6);
				name = name + "..."
			}
			LODOP.ADD_PRINT_TEXT(62 + j * linHight + h, 15, 150, 30, index + "、" + name);
			LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
			//数量
			LODOP.ADD_PRINT_TEXT(62 + j * linHight + h, 170, 50, 30, data.lines[i][j].FOOD_NUM);
			LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
			//单位
			LODOP.ADD_PRINT_TEXT(62 + j * linHight + h, 220, 40, 30, data.lines[i][j].CNAME);
			LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
			if (data.lines[i][j].DESCRIPTION != 0) {
				h = h + linHight;
				LODOP.ADD_PRINT_TEXT(62 + j * linHight + h, 15, 230, 30, "  备注：" + data.lines[i][j].DESCRIPTION);
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
			}

			var arr = data.lines[i][j].PRINTNAME.split(";"); //截取成数组

			BridgeIDandName = arr[0] + ";" + arr[1]; //端桥ID;端桥名称
			printerName = arr[2];	 //打印机名称 
			index++;
		}

		//菜品结束下划线
		LODOP.ADD_PRINT_LINE(62 + index * (linHight) + h, 15, 62 + index * (linHight) + h, 250, 0, 1);

		if (data.type == 1) {
			LODOP.ADD_PRINT_TEXT(70 + index * (linHight) + h, 15, 145, 30, "订单来源：店内点餐");
		} else {
			LODOP.ADD_PRINT_TEXT(70 + index * (linHight) + h, 15, 145, 30, "订单来源：线上点餐");
		}
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
		if (data.Description != "无") {
			LODOP.ADD_PRINT_TEXT(90 + index * (linHight) + h, 15, 250, 30, "特殊备注：" + data.Description);
			LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
			h = h + 20;
		}

		LODOP.ADD_PRINT_TEXT(90 + index * (linHight) + h, 65, 200, 30, data.NowDate);
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
		LODOP.SET_PRINT_STYLEA(0, "Alignment", 3);
		LODOP.ADD_PRINT_TEXT(110 + index * (linHight) + h, 45, 190, 35, "SEC·秒通云餐厅");
		LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
		LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
		// 设置打印机
		LODOP.SET_PRINTER_INDEX(DriverName + ',' + BridgeIDandName + ',' + printerName);
		// 打印
		var fl = LODOP.PRINT();
		console.log("打印结果：", fl)

		console.log("打印机的个数", LODOP.GET_PRINTER_COUNT())
	}
}
function print(data) {
	var DriverName = "(AO)Client-Bridge Driver"; //驱动名称
	var arr = data.printName.split(";");
	var BridgeIDandName = arr[0] + ";" + arr[1]; //端桥表示;端桥名称
	var printerName = arr[2]; 	 //打印机名称

	LODOP.SET_PRINTER_INDEX(DriverName + ',' + BridgeIDandName + ',' + printerName);
	//离纸张顶端0mm、距左边0mm、宽53mm、高9mm、内容为“桌号：24号桌”
	LODOP.ADD_PRINT_TEXT("0mm", "0mm", "53mm", "9mm", data.deskNo);
	LODOP.SET_PRINT_STYLEA(0, "FontSize", 15);// 字体大小
	LODOP.ADD_PRINT_TEXT("7mm", "0mm", "53mm", "7mm", "开单时间：" + data.createBillDate);
	LODOP.ADD_PRINT_TEXT("13mm", "0mm", "53mm", "7mm", "用餐人数：" + data.seat + "人");
	LODOP.ADD_PRINT_LINE("22mm", "0mm", "22mm", "50mm", 0, 1);
	LODOP.ADD_PRINT_TEXT("23mm", "0mm", "53mm", "8mm", "品名：             数量   总价");
	LODOP.ADD_PRINT_LINE("28mm", "0mm", "28mm", "50mm", 0, 1);
	var num = 30;
	var total = 0;
	for (var i = 0; i < data.lines.length; i++) {
		var line = data.lines[i];
		total = Number(total + Number(line.totalPrice));
		total = total.toFixed(2);
		total = Number(total);
		num = 30 + (i * 5);
		LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "58mm", "7mm", (i + 1) + "." + line.name);
		LODOP.ADD_PRINT_TEXT(num + "mm", "31mm", "58mm", "7mm", line.foodNum);
		LODOP.ADD_PRINT_TEXT(num + "mm", "40mm", "58mm", "7mm", line.totalPrice);
	}
	num = num + 5;
	LODOP.ADD_PRINT_LINE(num + "mm", "0mm", num + "mm", "50mm", 0, 1);
	num = num + 3;
	LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "53mm", "7mm", "合计： " + total + "    ");
	LODOP.SET_PRINT_STYLEA(0, "Alignment", 3);//右对齐
	num = num + 5;
	LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "53mm", "7mm", data.NowDate + "   ");
	LODOP.SET_PRINT_STYLEA(0, "Alignment", 3);//右对齐
	num = num + 5;
	LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "53mm", "7mm", "SEC·秒通云餐厅");
	LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);// 字体大小
	LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);//居中
	//  LODOP.PREVIEW(); //预览
	LODOP.PRINT();	 //打印
}
function printC(data) {

	var DriverName = "(AO)Client-Bridge Driver"; //驱动名称
	var arr = data.printName.split(";");
	var BridgeIDandName = arr[0] + ";" + arr[1]; //端桥表示;端桥名称
	var printerName = arr[2]; 	 //打印机名称

	LODOP.SET_PRINTER_INDEX(DriverName + ',' + BridgeIDandName + ',' + printerName);
	//离纸张顶端0mm、距左边0mm、宽53mm、高9mm、内容为“桌号：24号桌”
	LODOP.ADD_PRINT_TEXT("0mm", "0mm", "53mm", "9mm", data.deskNo);
	LODOP.SET_PRINT_STYLEA(0, "FontSize", 15);// 字体大小
	LODOP.ADD_PRINT_TEXT("7mm", "0mm", "53mm", "7mm", "开单时间：" + data.createBillDate);
	LODOP.ADD_PRINT_TEXT("13mm", "0mm", "53mm", "7mm", "用餐人数：" + data.seat + "人");
	LODOP.ADD_PRINT_LINE("22mm", "0mm", "22mm", "50mm", 0, 1);
	LODOP.ADD_PRINT_TEXT("23mm", "0mm", "53mm", "8mm", "品名：              数量  总价");
	LODOP.ADD_PRINT_LINE("28mm", "0mm", "28mm", "50mm", 0, 1);
	var num = 30;
	var total = 0;
	for (var i = 0; i < data.lines.length; i++) {
		var line = data.lines[i];
		total = Number(total + Number(line.TOTAL_PRICE));
		total = total.toFixed(2);
		total = Number(total);
		num = 30 + (i * 5);
		LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "58mm", "7mm", (i + 1) + "." + line.NAME + "        " + line.FOOD_NUM + "    " + line.TOTAL_PRICE);
	}
	num = num + 5;
	LODOP.ADD_PRINT_LINE(num + "mm", "0mm", num + "mm", "50mm", 0, 1);
	num = num + 3;
	LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "53mm", "7mm", "合计： " + total + "    ");
	LODOP.SET_PRINT_STYLEA(0, "Alignment", 3);//右对齐
	num = num + 5;
	LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "53mm", "7mm", data.NowDate + "   ");
	LODOP.SET_PRINT_STYLEA(0, "Alignment", 3);//右对齐
	num = num + 5;
	LODOP.ADD_PRINT_TEXT(num + "mm", "0mm", "53mm", "7mm", "SEC·秒通云餐厅");
	LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);// 字体大小
	LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);//居中
	//  LODOP.PREVIEW(); //预览
	LODOP.PRINT();	 //打印
}